1 #ifndef MISSING_INTEL_INTRINSICS_H_
2 #define MISSING_INTEL_INTRINSICS_H_
3 
4 #include <immintrin.h>
5 
6 // Old Visual Studio headers lack the bsrli variant
7 #ifndef _mm_bsrli_si128
8   #define _mm_bsrli_si128(a, imm8) _mm_srli_si128((a), (imm8))
9 #endif
10 
11 // GCC headers apparently won't have this at all.. sigh
12 #ifndef _andn_u32
13   // VS2015 headers apparently won't have this at all.. sigh
14   #ifdef __andn_u32
15     #define _andn_u32(x, y) (__andn_u32((x), (y)))
16   #else
17     #define _andn_u32(x, y) ((~(x)) & (y))
18   #endif // __andn_u32
19 #endif // _andn_u32
20 
21 // Some Visual Studio headers apparently lack these pseudoinstructions
22 #if COMPILE_INTEL_AVX2
23   #ifndef _mm256_bsrli_epi128
24     #define _mm256_bsrli_epi128(a, imm8) _mm256_srli_si256((a), (imm8))
25   #endif
26   #ifndef _mm256_insert_epi32
27     #define _mm256_insert_epi32(a, i, index) (_mm256_blend_epi32((a), _mm256_set1_epi32(i), (1 << (index))))
28   #endif
29 
30   #ifndef _mm256_extract_epi32
31     #define _mm256_extract_epi32(a, index) (_mm_extract_epi32(_mm256_extracti128_si256((a), (index) >> 2), (index) & 3))
32   #endif
33 #endif
34 
35 #endif
36