What are _mm256_testc_pd, _mm256_testz_pd, _mm256_testnzc_pd for?
I am trying to understand the _mm256_testc_pd
, _mm256_testz_pd
, and _mm256_testnzc_pd
intrinsics, and I have a hard time understanding them.
To analyze _mm256_testc_pd
, I have identified the following cases (a
is the first, b
the second __mm256d
argument`):
- If all packed doubles in
b
are > 0, thenZF=1
,CF=1
, except: - If one packed double in each
a
andb
are mutally < 0, thenZF=0
. - If one packed double in each
!a
andb
are mutually < 0, thenCF=0
.
In other words, a value of ZF=1
tells me that either a) b
is entirely positive, or b) that for those doubles in b
that are not positive, there is a matching double in a
that is negative. A value of CF=1
tells me that either c) b
is entirely positive, or d) that for those doubles in b
that are not positive, there is a matching double in in !a
that is negative.
Have I understood this correctly? I am a bit confused by this. What's the point of this check? What would I use these intrinsics for?
x86 sse simd intrinsics avx
add a comment |
I am trying to understand the _mm256_testc_pd
, _mm256_testz_pd
, and _mm256_testnzc_pd
intrinsics, and I have a hard time understanding them.
To analyze _mm256_testc_pd
, I have identified the following cases (a
is the first, b
the second __mm256d
argument`):
- If all packed doubles in
b
are > 0, thenZF=1
,CF=1
, except: - If one packed double in each
a
andb
are mutally < 0, thenZF=0
. - If one packed double in each
!a
andb
are mutually < 0, thenCF=0
.
In other words, a value of ZF=1
tells me that either a) b
is entirely positive, or b) that for those doubles in b
that are not positive, there is a matching double in a
that is negative. A value of CF=1
tells me that either c) b
is entirely positive, or d) that for those doubles in b
that are not positive, there is a matching double in in !a
that is negative.
Have I understood this correctly? I am a bit confused by this. What's the point of this check? What would I use these intrinsics for?
x86 sse simd intrinsics avx
1
The most common use case is testing the result of a compare operation, where the result elements are either all 1 or all 0 (so testing the sign bit is sufficient) - this enables you to implement predicates such as "all equal" or "any greater than" etc, using thetestz
intrinsic. (I've never found a use for any of the other variants).
– Paul R
Nov 21 '18 at 11:40
@PaulR: Might as well move that to an answer.
– Jason R
Nov 21 '18 at 13:01
@JasonR: yes, you're right - I got carried away with what was originally just going to be a short comment. ;-)
– Paul R
Nov 21 '18 at 13:07
1
Usually you usevptest
orvtestpd
with one operand being a constant mask, not two variables. e.g. to check for any element being negative (having its sign bit set). Related: Can PTEST be used to test if two registers are both zero or some other condition?.
– Peter Cordes
Nov 21 '18 at 16:53
add a comment |
I am trying to understand the _mm256_testc_pd
, _mm256_testz_pd
, and _mm256_testnzc_pd
intrinsics, and I have a hard time understanding them.
To analyze _mm256_testc_pd
, I have identified the following cases (a
is the first, b
the second __mm256d
argument`):
- If all packed doubles in
b
are > 0, thenZF=1
,CF=1
, except: - If one packed double in each
a
andb
are mutally < 0, thenZF=0
. - If one packed double in each
!a
andb
are mutually < 0, thenCF=0
.
In other words, a value of ZF=1
tells me that either a) b
is entirely positive, or b) that for those doubles in b
that are not positive, there is a matching double in a
that is negative. A value of CF=1
tells me that either c) b
is entirely positive, or d) that for those doubles in b
that are not positive, there is a matching double in in !a
that is negative.
Have I understood this correctly? I am a bit confused by this. What's the point of this check? What would I use these intrinsics for?
x86 sse simd intrinsics avx
I am trying to understand the _mm256_testc_pd
, _mm256_testz_pd
, and _mm256_testnzc_pd
intrinsics, and I have a hard time understanding them.
To analyze _mm256_testc_pd
, I have identified the following cases (a
is the first, b
the second __mm256d
argument`):
- If all packed doubles in
b
are > 0, thenZF=1
,CF=1
, except: - If one packed double in each
a
andb
are mutally < 0, thenZF=0
. - If one packed double in each
!a
andb
are mutually < 0, thenCF=0
.
In other words, a value of ZF=1
tells me that either a) b
is entirely positive, or b) that for those doubles in b
that are not positive, there is a matching double in a
that is negative. A value of CF=1
tells me that either c) b
is entirely positive, or d) that for those doubles in b
that are not positive, there is a matching double in in !a
that is negative.
Have I understood this correctly? I am a bit confused by this. What's the point of this check? What would I use these intrinsics for?
x86 sse simd intrinsics avx
x86 sse simd intrinsics avx
edited Nov 21 '18 at 13:10
Paul R
175k24297454
175k24297454
asked Nov 21 '18 at 11:04
mSSM
27438
27438
1
The most common use case is testing the result of a compare operation, where the result elements are either all 1 or all 0 (so testing the sign bit is sufficient) - this enables you to implement predicates such as "all equal" or "any greater than" etc, using thetestz
intrinsic. (I've never found a use for any of the other variants).
– Paul R
Nov 21 '18 at 11:40
@PaulR: Might as well move that to an answer.
– Jason R
Nov 21 '18 at 13:01
@JasonR: yes, you're right - I got carried away with what was originally just going to be a short comment. ;-)
– Paul R
Nov 21 '18 at 13:07
1
Usually you usevptest
orvtestpd
with one operand being a constant mask, not two variables. e.g. to check for any element being negative (having its sign bit set). Related: Can PTEST be used to test if two registers are both zero or some other condition?.
– Peter Cordes
Nov 21 '18 at 16:53
add a comment |
1
The most common use case is testing the result of a compare operation, where the result elements are either all 1 or all 0 (so testing the sign bit is sufficient) - this enables you to implement predicates such as "all equal" or "any greater than" etc, using thetestz
intrinsic. (I've never found a use for any of the other variants).
– Paul R
Nov 21 '18 at 11:40
@PaulR: Might as well move that to an answer.
– Jason R
Nov 21 '18 at 13:01
@JasonR: yes, you're right - I got carried away with what was originally just going to be a short comment. ;-)
– Paul R
Nov 21 '18 at 13:07
1
Usually you usevptest
orvtestpd
with one operand being a constant mask, not two variables. e.g. to check for any element being negative (having its sign bit set). Related: Can PTEST be used to test if two registers are both zero or some other condition?.
– Peter Cordes
Nov 21 '18 at 16:53
1
1
The most common use case is testing the result of a compare operation, where the result elements are either all 1 or all 0 (so testing the sign bit is sufficient) - this enables you to implement predicates such as "all equal" or "any greater than" etc, using the
testz
intrinsic. (I've never found a use for any of the other variants).– Paul R
Nov 21 '18 at 11:40
The most common use case is testing the result of a compare operation, where the result elements are either all 1 or all 0 (so testing the sign bit is sufficient) - this enables you to implement predicates such as "all equal" or "any greater than" etc, using the
testz
intrinsic. (I've never found a use for any of the other variants).– Paul R
Nov 21 '18 at 11:40
@PaulR: Might as well move that to an answer.
– Jason R
Nov 21 '18 at 13:01
@PaulR: Might as well move that to an answer.
– Jason R
Nov 21 '18 at 13:01
@JasonR: yes, you're right - I got carried away with what was originally just going to be a short comment. ;-)
– Paul R
Nov 21 '18 at 13:07
@JasonR: yes, you're right - I got carried away with what was originally just going to be a short comment. ;-)
– Paul R
Nov 21 '18 at 13:07
1
1
Usually you use
vptest
or vtestpd
with one operand being a constant mask, not two variables. e.g. to check for any element being negative (having its sign bit set). Related: Can PTEST be used to test if two registers are both zero or some other condition?.– Peter Cordes
Nov 21 '18 at 16:53
Usually you use
vptest
or vtestpd
with one operand being a constant mask, not two variables. e.g. to check for any element being negative (having its sign bit set). Related: Can PTEST be used to test if two registers are both zero or some other condition?.– Peter Cordes
Nov 21 '18 at 16:53
add a comment |
1 Answer
1
active
oldest
votes
The most common use case is testing the result of a compare operation, where the result elements from the comparison are either all 1 or all 0 (so testing the sign bit is sufficient) - this enables you to implement predicates such as "all equal" or "any greater than" etc, using the _mm*_testz_p*
intrinsic.
I've never found a use for any of the other variants.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53410744%2fwhat-are-mm256-testc-pd-mm256-testz-pd-mm256-testnzc-pd-for%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The most common use case is testing the result of a compare operation, where the result elements from the comparison are either all 1 or all 0 (so testing the sign bit is sufficient) - this enables you to implement predicates such as "all equal" or "any greater than" etc, using the _mm*_testz_p*
intrinsic.
I've never found a use for any of the other variants.
add a comment |
The most common use case is testing the result of a compare operation, where the result elements from the comparison are either all 1 or all 0 (so testing the sign bit is sufficient) - this enables you to implement predicates such as "all equal" or "any greater than" etc, using the _mm*_testz_p*
intrinsic.
I've never found a use for any of the other variants.
add a comment |
The most common use case is testing the result of a compare operation, where the result elements from the comparison are either all 1 or all 0 (so testing the sign bit is sufficient) - this enables you to implement predicates such as "all equal" or "any greater than" etc, using the _mm*_testz_p*
intrinsic.
I've never found a use for any of the other variants.
The most common use case is testing the result of a compare operation, where the result elements from the comparison are either all 1 or all 0 (so testing the sign bit is sufficient) - this enables you to implement predicates such as "all equal" or "any greater than" etc, using the _mm*_testz_p*
intrinsic.
I've never found a use for any of the other variants.
answered Nov 21 '18 at 13:07
Paul R
175k24297454
175k24297454
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53410744%2fwhat-are-mm256-testc-pd-mm256-testz-pd-mm256-testnzc-pd-for%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
The most common use case is testing the result of a compare operation, where the result elements are either all 1 or all 0 (so testing the sign bit is sufficient) - this enables you to implement predicates such as "all equal" or "any greater than" etc, using the
testz
intrinsic. (I've never found a use for any of the other variants).– Paul R
Nov 21 '18 at 11:40
@PaulR: Might as well move that to an answer.
– Jason R
Nov 21 '18 at 13:01
@JasonR: yes, you're right - I got carried away with what was originally just going to be a short comment. ;-)
– Paul R
Nov 21 '18 at 13:07
1
Usually you use
vptest
orvtestpd
with one operand being a constant mask, not two variables. e.g. to check for any element being negative (having its sign bit set). Related: Can PTEST be used to test if two registers are both zero or some other condition?.– Peter Cordes
Nov 21 '18 at 16:53