Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7942 Discussions

AVX2 _mm256_cmpgt_epi8/16/32/64 documentation omits signedness and doesn't specify result in case of equality

Nathan_Weeks
Beginner
412 Views

In the User and Reference Guide for the Intel C++ Compiler 15.0, the description of the AVX2 intrinsics _mm256_cmpgt_epi8/16/32/64 states:

Performs a SIMD compare to determine which of the data elements [packed bytes, words, doublewords, or quadwords] in source vector s1 is greater than the corresponding element in the source vector s2.

For each pair of data elements in source vectors, s1 and s2, if the s1 data element is greater than the corresponding element in s2, then the corresponding element in the destination vector is set to all 1s. If the s1 data element is less than the corresponding data element in s2, then the corresponding data element in destination vector is set to all 0s.

This does not specify the signedness of source vectors s1 and s2, which is relevant when determining if a data element of s1 is greater than the corresponding data element of s2, nor does the description define the value of resulting element of the destination vector when a data element of s1 equals the corresponding data element of s2

Per the description of the corresponding AVX2 instructions (VPCMPGTBVPCMPGTWVPCMPGTD, VPCMPGTQ)in the Intel 64 and IA-32 Architectures Software Developer's Manual, the _mm256_cmpgt_epi8/16/32/64 intrinsics performs a signed comparison; e.g., the description for VPCMPGTB/VPCMPGTW/VPCMPGTD states:

Performs an SIMD signed compare for the greater value of the packed byte, word, or doubleword integers in the destination operand (first operand) and the source operand (second operand). 

Also, the destination vector is set to 0 in the case of equality:

If the data element in the first (destination) operand is greater than the corresponding element in the second (source) operand, the corresponding data element in the destination is set to all 1s; otherwise, it is set to 0s. 

0 Kudos
1 Reply
Kittur_G_Intel
Employee
412 Views

Thanks Nathan, I've escalated this issue to the doc team and will keep you updated accordingly - appreciate much.

_Kittur 

0 Kudos
Reply