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

SIMD intrinsic _mm512_mask_cmp_epi8_mask returns wrong result with -O3 compile option

howin
Beginner
890 Views

Running the following code gets wrong result with `-O3` compilation option.

SIMD intrinsic `_mm512_mask_cmp_epi8_mask` returns incorrect result.

howin_0-1660139246618.png

OS: CentOS Linux release 7.9 (Final)

CPU: Intel(R) Xeon(R) Platinum 8255C CPU @ 2.50GHz

G++: 7.3.1

```

#include <immintrin.h>
#include <bitset>
#include <iostream>
#include <vector>

int main() {
std::vector<int8_t> a_data(64, 5);
std::vector<int8_t> b_data(64, 10);
__mmask64 mask = ((uint64_t)1 << 63) | (((uint64_t)1 << 63) - 1);
__m512i a = _mm512_loadu_si512(a_data.data());
__m512i b = _mm512_loadu_si512(b_data.data());
__mmask64 res1 = _mm512_mask_cmp_epi8_mask(mask, a, b, _MM_CMPINT_LT);
__mmask64 res2 = _mm512_mask_cmplt_epi8_mask(mask, a, b);

std::cout << "res1: " << std::hex << res1 << '\n' << "res2: " << std::hex << res2 << '\n';
}

```

Labels (1)
0 Kudos
4 Replies
HemanthCH_Intel
Moderator
857 Views

Hi,

 

Thanks for posting in Intel communities.

 

We did not observe any changes in the result even with -the O3 flag enabled using Intel compilers(icpc,icpx). Could you please try with the Intel Compilers and let us know if you face any issues?

HemanthCH_Intel_0-1660220531516.png

Please refer to the above screenshot for  more details.

 

Thanks & Regards,

Hemanth

 

0 Kudos
howin
Beginner
848 Views

How about using G++ 7.3.1?What I'm confused about is only this SIMD instrinsic returns an unexpected result.

0 Kudos
HemanthCH_Intel
Moderator
807 Views

Hi,


As we can see that you are compiling the code with Gcc, but works as expected with Intel C++ compilers. This forum is intended to support the queries related to the Intel C++ Compilers and other Intel oneAPI products. So, could you please let us know whether you have any issues with Intel oneAPI products?


Thanks & Regards,

Hemanth


0 Kudos
HemanthCH_Intel
Moderator
766 Views

Hi,


We assume that your issue is resolved. If you need any additional information, please post a new question as this thread will no longer be monitored by Intel.


Thanks & Regards,

Hemanth


0 Kudos
Reply