Reputation: 23
I've tried to compile a AVX2 program with gcc(g++). But it didn't work right.
#include<immintrin.h>
....
__m256i _vector256 = _mm256_loadu_si256((__m256i*)pin);
__m256i _vectorMask = _mm256_loadu_si256((__m256i*)mask_hbits);
_vector256 = _mm256_slli_epi32 (_vector256, AVX_LOGDESC); // AVX_LOGDESC == 4
__m256i _vectorRes = _mm256_and_si256(_vector256, _vectorMask);
....
My compile command is (as one line in Makefile):
g++ avx_shift.cpp -c -mavx2
I also tried this one:
g++ avx_shift.cpp -c -march=native
But the error messages were same:
/tmp/ccSFs6U0.s: Assembler messages:
/tmp/ccSFs6U0.s:1083: Error: suffix or operands invalid for `vpslld'
/tmp/ccSFs6U0.s:1091: Error: suffix or operands invalid for `vpand'
....
The assembly code (added the line number):
vmovdqa 988(%rsp), %ymm0 # __A, D.48219
movl 984(%rsp), %eax # __B, tmp205
movl %eax, -120(%rsp) # tmp205, %sfp
vmovd -120(%rsp), %xmm6 # %sfp, tmp205
vpslld %xmm6, %ymm0, %ymm0 # tmp205, D.48219, D.48220 // 1083
....
vmovdqa 668(%rsp), %ymm0 # __B, tmp220
vmovdqa 700(%rsp), %ymm1 # __A, tmp221
vpand %ymm0, %ymm1, %ymm0 # tmp220, tmp221, D.48215 // 1091
....
My gcc(g++) version is 4.8.0. My OS version is Centos6.5 X86_64. I've confirmed that my CPU supports AVX2 instructions. So who can help me find the errors?
Upvotes: 1
Views: 1713
Reputation: 58822
The two source lines you pasted shouldn't, and on my machine don't, generate any vpslld
or vpand
instructions. Use the -S -g -fverbose-asm
switches to ask for assembly source and try to find the matching source lines.
Upvotes: 3