What are _mm256_testc_pd, _mm256_testz_pd, _mm256_testnzc_pd for?












1














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, then ZF=1, CF=1, except:

  • If one packed double in each a and b are mutally < 0, then ZF=0.

  • If one packed double in each !a and b are mutually < 0, then CF=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?










share|improve this question




















  • 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 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
















1














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, then ZF=1, CF=1, except:

  • If one packed double in each a and b are mutally < 0, then ZF=0.

  • If one packed double in each !a and b are mutually < 0, then CF=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?










share|improve this question




















  • 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 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














1












1








1







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, then ZF=1, CF=1, except:

  • If one packed double in each a and b are mutally < 0, then ZF=0.

  • If one packed double in each !a and b are mutually < 0, then CF=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?










share|improve this question















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, then ZF=1, CF=1, except:

  • If one packed double in each a and b are mutally < 0, then ZF=0.

  • If one packed double in each !a and b are mutually < 0, then CF=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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 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 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














  • 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 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








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












1 Answer
1






active

oldest

votes


















2














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.






share|improve this answer





















    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
    });


    }
    });














    draft saved

    draft discarded


















    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









    2














    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.






    share|improve this answer


























      2














      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.






      share|improve this answer
























        2












        2








        2






        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.






        share|improve this answer












        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.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 21 '18 at 13:07









        Paul R

        175k24297454




        175k24297454






























            draft saved

            draft discarded




















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            404 Error Contact Form 7 ajax form submitting

            How to know if a Active Directory user can login interactively

            TypeError: fit_transform() missing 1 required positional argument: 'X'