Debian Codegraph @

clang/test/CodeGen/X86/avx2-builtins.c

raw
1 // RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx2 -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes=CHECK,X64
2 // RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx2 -fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes=CHECK,X64
3 // RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=i386-apple-darwin -target-feature +avx2 -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes=CHECK,X86
4 // RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=i386-apple-darwin -target-feature +avx2 -fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes=CHECK,X86
5 // RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx2 -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes=CHECK,X64
6 // RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx2 -fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes=CHECK,X64
7 // RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=i386-apple-darwin -target-feature +avx2 -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes=CHECK,X86
8 // RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=i386-apple-darwin -target-feature +avx2 -fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes=CHECK,X86
9
10 // RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx2 -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s --check-prefixes=CHECK,X64
11 // RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx2 -fno-signed-char -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s --check-prefixes=CHECK,X64
12 // RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=i386-apple-darwin -target-feature +avx2 -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s --check-prefixes=CHECK,X86
13 // RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=i386-apple-darwin -target-feature +avx2 -fno-signed-char -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s --check-prefixes=CHECK,X86
14 // RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx2 -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s --check-prefixes=CHECK,X64
15 // RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx2 -fno-signed-char -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s --check-prefixes=CHECK,X64
16 // RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=i386-apple-darwin -target-feature +avx2 -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s --check-prefixes=CHECK,X86
17 // RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=i386-apple-darwin -target-feature +avx2 -fno-signed-char -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s --check-prefixes=CHECK,X86
18
19 #include <immintrin.h>
20 #include "builtin_test_helpers.h"
21
22 // NOTE: This should match the tests in llvm/test/CodeGen/X86/avx2-intrinsics-fast-isel.ll
23
24 __m256i test_mm256_abs_epi8(__m256i a) {
25 // CHECK-LABEL: test_mm256_abs_epi8
26 // CHECK: [[ABS:%.*]] = call <32 x i8> @llvm.abs.v32i8(<32 x i8> %{{.*}}, i1 false)
27 return _mm256_abs_epi8(a);
28 }
29 TEST_CONSTEXPR(match_v32qi(_mm256_abs_epi8((__m256i)(__v32qs){0, +1, +2, +3, +4, +5, +6, +7, +8, +9, +10, +11, +12, +13, +14, +15, +100, +50, -100, +20, +80, -50, +120, -20, -100, -50, +100, -20, -80, +50, -120, +20}), 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 100, 50, 100, 20, 80, 50, 120, 20, 100, 50, 100, 20, 80, 50, 120, 20));
30
31 __m256i test_mm256_abs_epi16(__m256i a) {
32 // CHECK-LABEL: test_mm256_abs_epi16
33 // CHECK: [[ABS:%.*]] = call <16 x i16> @llvm.abs.v16i16(<16 x i16> %{{.*}}, i1 false)
34 return _mm256_abs_epi16(a);
35 }
36 TEST_CONSTEXPR(match_v16hi(_mm256_abs_epi16((__m256i)(__v16hi){+5, -3, -32767, +32767, -10, +8, 0, -256, +256, -128, +3, +9, +15, +33, +63, +129}), 5, 3, 32767, 32767, 10, 8, 0, 256, 256, 128, 3, 9, 15, 33, 63, 129));
37
38 __m256i test_mm256_abs_epi32(__m256i a) {
39 // CHECK-LABEL: test_mm256_abs_epi32
40 // CHECK: [[ABS:%.*]] = call <8 x i32> @llvm.abs.v8i32(<8 x i32> %{{.*}}, i1 false)
41 return _mm256_abs_epi32(a);
42 }
43 TEST_CONSTEXPR(match_v8si(_mm256_abs_epi32((__m256i)(__v8si){+5, -3, -2147483647, +2147483647, 0, -256, +256, +1025}), 5, 3, 2147483647, 2147483647, 0, 256, 256, 1025));
44
45 __m256i test_mm256_add_epi8(__m256i a, __m256i b) {
46 // CHECK-LABEL: test_mm256_add_epi8
47 // CHECK: add <32 x i8>
48 return _mm256_add_epi8(a, b);
49 }
50
51 TEST_CONSTEXPR(match_v32qi(_mm256_add_epi8((__m256i)(__v32qs){ -64, -65, 66, 67, 68, -69, -70, -71, -72, 73, 74, -75, 76, 77, -78, 79, -80, 81, 82, -83, 84, -85, 86, 87, -88, -89, -90, 91, -92, 93, 94, 95}, (__m256i)(__v32qs){ -1, -2, 3, -4, 5, -6, 7, 8, 9, -10, 11, -12, 13, 14, 15, 16, -17, 18, 19, 20, -21, 22, -23, -24, 25, 26, -27, -28, -29, 30, -31, 32}), -65, -67, 69, 63, 73, -75, -63, -63, -63, 63, 85, -87, 89, 91, -63, 95, -97, 99, 101, -63, 63, -63, 63, 63, -63, -63, -117, 63, -121, 123, 63, 127));
52
53 __m256i test_mm256_add_epi16(__m256i a, __m256i b) {
54 // CHECK-LABEL: test_mm256_add_epi16
55 // CHECK: add <16 x i16>
56 return _mm256_add_epi16(a, b);
57 }
58
59 TEST_CONSTEXPR(match_v16hi(_mm256_add_epi16((__m256i)(__v16hi){ -32, -33, 34, -35, -36, 37, -38, -39, -40, -41, -42, 43, -44, -45, 46, 47}, (__m256i)(__v16hi){ -1, 2, 3, -4, 5, -6, 7, 8, 9, 10, -11, -12, -13, 14, -15, -16}), -33, -31, 37, -39, -31, 31, -31, -31, -31, -31, -53, 31, -57, -31, 31, 31));
60
61 __m256i test_mm256_add_epi32(__m256i a, __m256i b) {
62 // CHECK-LABEL: test_mm256_add_epi32
63 // CHECK: add <8 x i32>
64 return _mm256_add_epi32(a, b);
65 }
66
67 TEST_CONSTEXPR(match_v8si(_mm256_add_epi32((__m256i)(__v8si){ 16, 17, 18, -19, 20, -21, 22, 23}, (__m256i)(__v8si){ -1, 2, 3, 4, 5, 6, 7, 8}), 15, 19, 21, -15, 25, -15, 29, 31));
68
69 __m256i test_mm256_add_epi64(__m256i a, __m256i b) {
70 // CHECK-LABEL: test_mm256_add_epi64
71 // CHECK: add <4 x i64>
72 return _mm256_add_epi64(a, b);
73 }
74
75 TEST_CONSTEXPR(match_v4di(_mm256_add_epi64((__m256i)(__v4di){ 8, -9, 10, 11}, (__m256i)(__v4di){ -1, -2, 3, 4}), 7, -11, 13, 15));
76
77 __m256i test_mm256_adds_epi8(__m256i a, __m256i b) {
78 // CHECK-LABEL: test_mm256_adds_epi8
79 // CHECK: call <32 x i8> @llvm.sadd.sat.v32i8(<32 x i8> %{{.*}}, <32 x i8> %{{.*}})
80 return _mm256_adds_epi8(a, b);
81 }
82 TEST_CONSTEXPR(match_v32qi(_mm256_adds_epi8((__m256i)(__v32qs){0, +1, +2, +3, +4, +5, +6, +7, +8, +9, +10, +11, +12, +13, +14, +15, +100, +50, -100, +20, +80, -50, +120, -20, -100, -50, +100, -20, -80, +50, -120, +20}, (__m256i)(__v32qs){0, +1, +2, +3, +4, +5, +6, +7, +8, +9, +10, +11, +12, +13, +14, +15, +50, +80, -50, +110, +60, -30, +20, -10, +50, +80, -50, +110, +60, -30, +20, -10}), 0, +2, +4, +6, +8, +10, +12, +14, +16, +18, +20, +22, +24, +26, +28, +30, +127, +127, -128, +127, +127, -80, +127, -30, -50, +30, +50, +90, -20, +20, -100, +10));
83
84 __m256i test_mm256_adds_epi16(__m256i a, __m256i b) {
85 // CHECK-LABEL: test_mm256_adds_epi16
86 // CHECK: call <16 x i16> @llvm.sadd.sat.v16i16(<16 x i16> %{{.*}}, <16 x i16> %{{.*}})
87 return _mm256_adds_epi16(a, b);
88 }
89 TEST_CONSTEXPR(match_v16hi(_mm256_adds_epi16((__m256i)(__v16hi){0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, +32000, -32000, +32000, -32000}, (__m256i)(__v16hi){0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, +800, -800, -800, +800}), 0, -2, -4, -6, -8, -10, -12, -14, -16, -18, -20, -22, +32767, -32768, +31200, -31200));
90
91 __m256i test_mm256_adds_epu8(__m256i a, __m256i b) {
92 // CHECK-LABEL: test_mm256_adds_epu8
93 // CHECK-NOT: call <32 x i8> @llvm.x86.avx2.paddus.b(<32 x i8> %{{.*}}, <32 x i8> %{{.*}})
94 // CHECK: call <32 x i8> @llvm.uadd.sat.v32i8(<32 x i8> %{{.*}}, <32 x i8> %{{.*}})
95 return _mm256_adds_epu8(a, b);
96 }
97 TEST_CONSTEXPR(match_v32qu(_mm256_adds_epu8((__m256i)(__v32qu){0, 0, 0, 0, +64, +64, +64, +64, +64, +64, +127, +127, +127, +127, +127, +127, +128, +128, +128, +128, +128, +128, +192, +192, +192, +192, +192, +192, +255, +255, +255, +255}, (__m256i)(__v32qu){0, +127, +128, +255, 0, +64, +127, +128, +192, +255, 0, +64, +127, +128, +192, +255, 0, +64, +127, +128, +192, +255, 0, +64, +127, +128, +192, +255, 0, +127, +128, +255}), 0, +127, +128, +255, +64, +128, +191, +192, +255, +255, +127, +191, +254, +255, +255, +255, +128, +192, +255, +255, +255, +255, +192, +255, +255, +255, +255, +255, +255, +255, +255, +255));
98
99 __m256i test_mm256_adds_epu16(__m256i a, __m256i b) {
100 // CHECK-LABEL: test_mm256_adds_epu16
101 // CHECK-NOT: call <16 x i16> @llvm.x86.avx2.paddus.w(<16 x i16> %{{.*}}, <16 x i16> %{{.*}})
102 // CHECK: call <16 x i16> @llvm.uadd.sat.v16i16(<16 x i16> %{{.*}}, <16 x i16> %{{.*}})
103 return _mm256_adds_epu16(a, b);
104 }
105 TEST_CONSTEXPR(match_v16hu(_mm256_adds_epu16((__m256i)(__v16hu){0, 0, 0, 0, +32767, +32767, +32767, +32767, +32768, +32768, +32768, +32768, +65535, +65535, +65535, +65535}, (__m256i)(__v16hu){0, +32767, +32768, +65535, 0, +32767, +32768, +65535, 0, +32767, +32768, +65535, 0, +32767, +32768, +65535}), 0, +32767, +32768, +65535, +32767, +65534, +65535, +65535, +32768, +65535, +65535, +65535, +65535, +65535, +65535, +65535));
106
107 __m256i test_mm256_alignr_epi8(__m256i a, __m256i b) {
108 // CHECK-LABEL: test_mm256_alignr_epi8
109 // CHECK: shufflevector <32 x i8> %{{.*}}, <32 x i8> %{{.*}}, <32 x i32> <i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 32, i32 33, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31, i32 48, i32 49>
110 return _mm256_alignr_epi8(a, b, 2);
111 }
112 TEST_CONSTEXPR(match_v32qi(_mm256_alignr_epi8(((__m256i)(__v32qs){1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32}), ((__m256i)(__v32qs){33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64}), 2), 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 1, 2, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 17, 18));
113 TEST_CONSTEXPR(match_v32qi(_mm256_alignr_epi8(((__m256i)(__v32qs){1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32}), ((__m256i)(__v32qs){33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64}), 16), 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32));
114 TEST_CONSTEXPR(match_v32qi(_mm256_alignr_epi8(((__m256i)(__v32qs){1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32}), ((__m256i)(__v32qs){33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64}), 32), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
115
116 __m256i test2_mm256_alignr_epi8(__m256i a, __m256i b) {
117 // CHECK-LABEL: test2_mm256_alignr_epi8
118 // CHECK: shufflevector <32 x i8> %{{.*}}, <32 x i8> zeroinitializer, <32 x i32> <i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 32, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31, i32 48>
119 return _mm256_alignr_epi8(a, b, 17);
120 }
121
122 __m256i test_mm256_and_si256(__m256i a, __m256i b) {
123 // CHECK-LABEL: test_mm256_and_si256
124 // CHECK: and <4 x i64>
125 return _mm256_and_si256(a, b);
126 }
127 TEST_CONSTEXPR(match_v4di(_mm256_and_si256((__m256i)(__v4di){0, -1, 0, -1}, (__m256i)(__v4di){0, 0, -1, -1}), 0, 0, 0, -1));
128
129 __m256i test_mm256_andnot_si256(__m256i a, __m256i b) {
130 // CHECK-LABEL: test_mm256_andnot_si256
131 // CHECK: xor <4 x i64>
132 // CHECK: and <4 x i64>
133 return _mm256_andnot_si256(a, b);
134 }
135 TEST_CONSTEXPR(match_v4di(_mm256_andnot_si256((__m256i)(__v4di){0, -1, 0, -1}, (__m256i)(__v4di){0, 0, -1, -1}), 0, 0, -1, 0));
136
137 __m256i test_mm256_avg_epu8(__m256i a, __m256i b) {
138 // CHECK-LABEL: test_mm256_avg_epu8
139 // CHECK: call <32 x i8> @llvm.x86.avx2.pavg.b(<32 x i8> %{{.*}}, <32 x i8> %{{.*}})
140 return _mm256_avg_epu8(a, b);
141 }
142 TEST_CONSTEXPR(match_v32qu(_mm256_avg_epu8((__m256i)(__v32qu){1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32}, (__m256i)(__v32qu){1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32}), 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32));
143
144 __m256i test_mm256_avg_epu16(__m256i a, __m256i b) {
145 // CHECK-LABEL: test_mm256_avg_epu16
146 // CHECK: call <16 x i16> @llvm.x86.avx2.pavg.w(<16 x i16> %{{.*}}, <16 x i16> %{{.*}})
147 return _mm256_avg_epu16(a, b);
148 }
149 TEST_CONSTEXPR(match_v16hu(_mm256_avg_epu16((__m256i)(__v16hu){1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}, (__m256i)(__v16hu){1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}), 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16));
150
151 // FIXME: We should also lower the __builtin_ia32_pblendw128 (and similar)
152 // functions to this IR. In the future we could delete the corresponding
153 // intrinsic in LLVM if it's not being used anymore.
154 __m256i test_mm256_blend_epi16(__m256i a, __m256i b) {
155 // CHECK-LABEL: test_mm256_blend_epi16
156 // CHECK-NOT: @llvm.x86.avx2.pblendw
157 // CHECK: shufflevector <16 x i16> %{{.*}}, <16 x i16> %{{.*}}, <16 x i32> <i32 0, i32 17, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 25, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
158 return _mm256_blend_epi16(a, b, 2);
159 }
160 TEST_CONSTEXPR(match_v16hi(_mm256_blend_epi16(((__m256i)(__v16hi){1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}), ((__m256i)(__v16hi){-1,-2,-3,-4,-5,-6,-7,-8,-9,-10,-11,-12,-13,-14,-15,-16}), 0x00), 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16));
161 TEST_CONSTEXPR(match_v16hi(_mm256_blend_epi16(((__m256i)(__v16hi){1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}), ((__m256i)(__v16hi){-1,-2,-3,-4,-5,-6,-7,-8,-9,-10,-11,-12,-13,-14,-15,-16}), 0x5A), 1,-2,3,-4,-5,6,-7,8,9,-10,11,-12,-13,14,-15,16));
162 TEST_CONSTEXPR(match_v16hi(_mm256_blend_epi16(((__m256i)(__v16hi){1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}), ((__m256i)(__v16hi){-1,-2,-3,-4,-5,-6,-7,-8,-9,-10,-11,-12,-13,-14,-15,-16}), 0x94), 1,2,-3,4,-5,6,7,-8,9,10,-11,12,-13,14,15,-16));
163 TEST_CONSTEXPR(match_v16hi(_mm256_blend_epi16(((__m256i)(__v16hi){1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}), ((__m256i)(__v16hi){-1,-2,-3,-4,-5,-6,-7,-8,-9,-10,-11,-12,-13,-14,-15,-16}), 0xFF), -1,-2,-3,-4,-5,-6,-7,-8,-9,-10,-11,-12,-13,-14,-15,-16));
164
165 __m128i test_mm_blend_epi32(__m128i a, __m128i b) {
166 // CHECK-LABEL: test_mm_blend_epi32
167 // CHECK-NOT: @llvm.x86.avx2.pblendd.128
168 // CHECK: shufflevector <4 x i32> %{{.*}}, <4 x i32> %{{.*}}, <4 x i32> <i32 4, i32 1, i32 6, i32 3>
169 return _mm_blend_epi32(a, b, 0x05);
170 }
171 TEST_CONSTEXPR(match_v4si(_mm_blend_epi32(((__m128i)(__v4si){1,2,3,4}), ((__m128i)(__v4si){-1,-2,-3,-4}), 0x0), 1,2,3,4));
172 TEST_CONSTEXPR(match_v4si(_mm_blend_epi32(((__m128i)(__v4si){1,2,3,4}), ((__m128i)(__v4si){-1,-2,-3,-4}), 0x5), -1,2,-3,4));
173 TEST_CONSTEXPR(match_v4si(_mm_blend_epi32(((__m128i)(__v4si){1,2,3,4}), ((__m128i)(__v4si){-1,-2,-3,-4}), 0xA), 1,-2,3,-4));
174 TEST_CONSTEXPR(match_v4si(_mm_blend_epi32(((__m128i)(__v4si){1,2,3,4}), ((__m128i)(__v4si){-1,-2,-3,-4}), 0xF), -1,-2,-3,-4));
175
176 __m256i test_mm256_blend_epi32(__m256i a, __m256i b) {
177 // CHECK-LABEL: test_mm256_blend_epi32
178 // CHECK-NOT: @llvm.x86.avx2.pblendd.256
179 // CHECK: shufflevector <8 x i32> %{{.*}}, <8 x i32> %{{.*}}, <8 x i32> <i32 8, i32 1, i32 10, i32 3, i32 12, i32 13, i32 6, i32 7>
180 return _mm256_blend_epi32(a, b, 0x35);
181 }
182 TEST_CONSTEXPR(match_v8si(_mm256_blend_epi32(((__m256i)(__v8si){1,2,3,4,5,6,7,8}), ((__m256i)(__v8si){-1,-2,-3,-4,-5,-6,-7,-8}), 0x00), 1,2,3,4,5,6,7,8));
183 TEST_CONSTEXPR(match_v8si(_mm256_blend_epi32(((__m256i)(__v8si){1,2,3,4,5,6,7,8}), ((__m256i)(__v8si){-1,-2,-3,-4,-5,-6,-7,-8}), 0xA5), -1,2,-3,4,5,-6,7,-8));
184 TEST_CONSTEXPR(match_v8si(_mm256_blend_epi32(((__m256i)(__v8si){1,2,3,4,5,6,7,8}), ((__m256i)(__v8si){-1,-2,-3,-4,-5,-6,-7,-8}), 0x94), 1,2,-3,4,-5,6,7,-8));
185 TEST_CONSTEXPR(match_v8si(_mm256_blend_epi32(((__m256i)(__v8si){1,2,3,4,5,6,7,8}), ((__m256i)(__v8si){-1,-2,-3,-4,-5,-6,-7,-8}), 0xFF), -1,-2,-3,-4,-5,-6,-7,-8));
186
187 __m256i test_mm256_blendv_epi8(__m256i a, __m256i b, __m256i m) {
188 // CHECK-LABEL: test_mm256_blendv_epi8
189 // CHECK: call <32 x i8> @llvm.x86.avx2.pblendvb(<32 x i8> %{{.*}}, <32 x i8> %{{.*}}, <32 x i8> %{{.*}})
190 return _mm256_blendv_epi8(a, b, m);
191 }
192 TEST_CONSTEXPR(match_v32qi(_mm256_blendv_epi8((__m256i)(__v32qs){0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31},(__m256i)(__v32qs){-90,-91,-92,-93,-94,-95,-96,-97,-98,-99,-100,-101,-12,-13,-104,-105,-106,-107,-108,-109,-100,-101,-12,-13,-104,-105,-106,-107,-108,-109,-120,-121},(__m256i)(__v32qs){0,0,0,-1,0,-1,-1,0,0,0,-1,-1,0,-1,0,0,0,0,0,0,0,0,0,-1,-1,-1,0,0,0,0,0,-1}), 0, 1, 2, -93, 4, -95, -96, 7, 8, 9, -100, -101, 12, -13, 14, 15, 16, 17, 18, 19, 20, 21, 22, -13, -104, -105, 26, 27, 28, 29, 30, -121));
193
194 __m128i test_mm_broadcastb_epi8(__m128i a) {
195 // CHECK-LABEL: test_mm_broadcastb_epi8
196 // CHECK-NOT: @llvm.x86.avx2.pbroadcastb.128
197 // CHECK: shufflevector <16 x i8> %{{.*}}, <16 x i8> %{{.*}}, <16 x i32> zeroinitializer
198 return _mm_broadcastb_epi8(a);
199 }
200 TEST_CONSTEXPR(match_v16qi(_mm_broadcastb_epi8((__m128i)(__v16qi){42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}), 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42));
201
202 __m256i test_mm256_broadcastb_epi8(__m128i a) {
203 // CHECK-LABEL: test_mm256_broadcastb_epi8
204 // CHECK-NOT: @llvm.x86.avx2.pbroadcastb.256
205 // CHECK: shufflevector <16 x i8> %{{.*}}, <16 x i8> %{{.*}}, <32 x i32> zeroinitializer
206 return _mm256_broadcastb_epi8(a);
207 }
208 TEST_CONSTEXPR(match_v32qi(_mm256_broadcastb_epi8((__m128i)(__v16qi){42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}), 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42));
209
210 __m128i test_mm_broadcastd_epi32(__m128i a) {
211 // CHECK-LABEL: test_mm_broadcastd_epi32
212 // CHECK-NOT: @llvm.x86.avx2.pbroadcastd.128
213 // CHECK: shufflevector <4 x i32> %{{.*}}, <4 x i32> %{{.*}}, <4 x i32> zeroinitializer
214 return _mm_broadcastd_epi32(a);
215 }
216 TEST_CONSTEXPR(match_v4si(_mm_broadcastd_epi32((__m128i)(__v4si){-42, 0, 0, 0}), -42, -42, -42, -42));
217
218 __m256i test_mm256_broadcastd_epi32(__m128i a) {
219 // CHECK-LABEL: test_mm256_broadcastd_epi32
220 // CHECK-NOT: @llvm.x86.avx2.pbroadcastd.256
221 // CHECK: shufflevector <4 x i32> %{{.*}}, <4 x i32> %{{.*}}, <8 x i32> zeroinitializer
222 return _mm256_broadcastd_epi32(a);
223 }
224 TEST_CONSTEXPR(match_v8si(_mm256_broadcastd_epi32((__m128i)(__v4si){-42, 0, 0, 0}), -42, -42, -42, -42, -42, -42, -42, -42));
225
226 __m128i test_mm_broadcastq_epi64(__m128i a) {
227 // CHECK-LABEL: test_mm_broadcastq_epi64
228 // CHECK-NOT: @llvm.x86.avx2.pbroadcastq.128
229 // CHECK: shufflevector <2 x i64> %{{.*}}, <2 x i64> %{{.*}}, <2 x i32> zeroinitializer
230 return _mm_broadcastq_epi64(a);
231 }
232 TEST_CONSTEXPR(match_v2di(_mm_broadcastq_epi64((__m128i)(__v2di){-42, 0}), -42, -42));
233
234 __m256i test_mm256_broadcastq_epi64(__m128i a) {
235 // CHECK-LABEL: test_mm256_broadcastq_epi64
236 // CHECK-NOT: @llvm.x86.avx2.pbroadcastq.256
237 // CHECK: shufflevector <2 x i64> %{{.*}}, <2 x i64> %{{.*}}, <4 x i32> zeroinitializer
238 return _mm256_broadcastq_epi64(a);
239 }
240 TEST_CONSTEXPR(match_v4di(_mm256_broadcastq_epi64((__m128i)(__v2di){-42, 0}), -42, -42, -42, -42));
241
242 __m128d test_mm_broadcastsd_pd(__m128d a) {
243 // CHECK-LABEL: test_mm_broadcastsd_pd
244 // CHECK: shufflevector <2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x i32> zeroinitializer
245 return _mm_broadcastsd_pd(a);
246 }
247 TEST_CONSTEXPR(match_m128d(_mm_broadcastsd_pd((__m128d){+7.0, -7.0}), +7.0, +7.0));
248
249 __m256d test_mm256_broadcastsd_pd(__m128d a) {
250 // CHECK-LABEL: test_mm256_broadcastsd_pd
251 // CHECK-NOT: @llvm.x86.avx2.vbroadcast.sd.pd.256
252 // CHECK: shufflevector <2 x double> %{{.*}}, <2 x double> %{{.*}}, <4 x i32> zeroinitializer
253 return _mm256_broadcastsd_pd(a);
254 }
255 TEST_CONSTEXPR(match_m256d(_mm256_broadcastsd_pd((__m128d){+7.0, -7.0}), +7.0, +7.0, +7.0, +7.0));
256
257 __m256i test_mm256_broadcastsi128_si256(__m128i a) {
258 // CHECK-LABEL: test_mm256_broadcastsi128_si256
259 // CHECK: shufflevector <2 x i64> %{{.*}}, <2 x i64> %{{.*}}, <4 x i32> <i32 0, i32 1, i32 0, i32 1>
260 return _mm256_broadcastsi128_si256(a);
261 }
262 TEST_CONSTEXPR(match_m256i(_mm256_broadcastsi128_si256((__m128i)(__v2di){3, 45}), 3, 45, 3, 45));
263
264 __m256i test_mm_broadcastsi128_si256(__m128i a) {
265 // CHECK-LABEL: test_mm_broadcastsi128_si256
266 // CHECK: shufflevector <2 x i64> %{{.*}}, <2 x i64> %{{.*}}, <4 x i32> <i32 0, i32 1, i32 0, i32 1>
267 return _mm_broadcastsi128_si256(a);
268 }
269 TEST_CONSTEXPR(match_m256i(_mm_broadcastsi128_si256(((__m128i)(__v2di){42, -99})), 42, -99, 42, -99));
270
271 __m128 test_mm_broadcastss_ps(__m128 a) {
272 // CHECK-LABEL: test_mm_broadcastss_ps
273 // CHECK-NOT: @llvm.x86.avx2.vbroadcast.ss.ps
274 // CHECK: shufflevector <4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x i32> zeroinitializer
275 return _mm_broadcastss_ps(a);
276 }
277 TEST_CONSTEXPR(match_m128(_mm_broadcastss_ps((__m128){-4.0f, +5.0f, +6.0f, +7.0f}), -4.0f, -4.0f, -4.0f, -4.0f));
278
279 __m256 test_mm256_broadcastss_ps(__m128 a) {
280 // CHECK-LABEL: test_mm256_broadcastss_ps
281 // CHECK-NOT: @llvm.x86.avx2.vbroadcast.ss.ps.256
282 // CHECK: shufflevector <4 x float> %{{.*}}, <4 x float> %{{.*}}, <8 x i32> zeroinitializer
283 return _mm256_broadcastss_ps(a);
284 }
285 TEST_CONSTEXPR(match_m256(_mm256_broadcastss_ps((__m128){-4.0f, +5.0f, +6.0f, +7.0f}), -4.0f, -4.0f, -4.0f, -4.0f, -4.0f, -4.0f, -4.0f, -4.0f));
286
287 __m128i test_mm_broadcastw_epi16(__m128i a) {
288 // CHECK-LABEL: test_mm_broadcastw_epi16
289 // CHECK-NOT: @llvm.x86.avx2.pbroadcastw.128
290 // CHECK: shufflevector <8 x i16> %{{.*}}, <8 x i16> %{{.*}}, <8 x i32> zeroinitializer
291 return _mm_broadcastw_epi16(a);
292 }
293 TEST_CONSTEXPR(match_v8hi(_mm_broadcastw_epi16((__m128i)(__v8hi){42, 0, 0, 0, 0, 0, 0, 0}), 42, 42, 42, 42, 42, 42, 42, 42));
294
295 __m256i test_mm256_broadcastw_epi16(__m128i a) {
296 // CHECK-LABEL: test_mm256_broadcastw_epi16
297 // CHECK-NOT: @llvm.x86.avx2.pbroadcastw.256
298 // CHECK: shufflevector <8 x i16> %{{.*}}, <8 x i16> %{{.*}}, <16 x i32> zeroinitializer
299 return _mm256_broadcastw_epi16(a);
300 }
301 TEST_CONSTEXPR(match_v16hi(_mm256_broadcastw_epi16((__m128i)(__v8hi){42, 0, 0, 0, 0, 0, 0, 0}), 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42));
302
303 __m256i test_mm256_bslli_epi128(__m256i a) {
304 // CHECK-LABEL: test_mm256_bslli_epi128
305 // CHECK: shufflevector <32 x i8> zeroinitializer, <32 x i8> %{{.*}}, <32 x i32> <i32 13, i32 14, i32 15, i32 32, i32 33, i32 34, i32 35, i32 36, i32 37, i32 38, i32 39, i32 40, i32 41, i32 42, i32 43, i32 44, i32 29, i32 30, i32 31, i32 48, i32 49, i32 50, i32 51, i32 52, i32 53, i32 54, i32 55, i32 56, i32 57, i32 58, i32 59, i32 60>
306 return _mm256_bslli_epi128(a, 3);
307 }
308 TEST_CONSTEXPR(match_v32qi(_mm256_bslli_epi128(((__m256i)(__v32qi){1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32}), 3), 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0, 0, 0, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29));
309 TEST_CONSTEXPR(match_v32qi(_mm256_bslli_epi128(((__m256i)(__v32qi){1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32}), 16), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
310
311 __m256i test_mm256_bsrli_epi128(__m256i a) {
312 // CHECK-LABEL: test_mm256_bsrli_epi128
313 // CHECK: shufflevector <32 x i8> %{{.*}}, <32 x i8> zeroinitializer, <32 x i32> <i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 32, i32 33, i32 34, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31, i32 48, i32 49, i32 50>
314 return _mm256_bsrli_epi128(a, 3);
315 }
316 TEST_CONSTEXPR(match_v32qi(_mm256_bsrli_epi128(((__m256i)(__v32qi){1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32}), 3), 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 0, 0, 0, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 0, 0, 0));
317 TEST_CONSTEXPR(match_v32qi(_mm256_bsrli_epi128(((__m256i)(__v32qi){1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32}), 16), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
318
319 __m256i test_mm256_cmpeq_epi8(__m256i a, __m256i b) {
320 // CHECK-LABEL: test_mm256_cmpeq_epi8
321 // CHECK: icmp eq <32 x i8>
322 return _mm256_cmpeq_epi8(a, b);
323 }
324 TEST_CONSTEXPR(match_v32qi(_mm256_cmpeq_epi8(
325 (__m256i)(__v32qs){1,-2,3,-4,-5,6,-7,8,-9,10,-11,12,-13,14,-15,16,-16,15,-14,13,-12,11,-10,9,-8,7,-6,5,4,-3,2,-1},
326 (__m256i)(__v32qs){10,-2,6,-4,-5,12,-14,8,-9,20,-22,12,-26,14,-30,16,10,-2,6,-4,-5,12,-14,8,-9,20,-22,12,-26,14,-30,16}),
327 0, -1, 0, -1, -1, 0, 0, -1, -1, 0, 0, -1, 0, -1, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
328
329 __m256i test_mm256_cmpeq_epi16(__m256i a, __m256i b) {
330 // CHECK-LABEL: test_mm256_cmpeq_epi16
331 // CHECK: icmp eq <16 x i16>
332 return _mm256_cmpeq_epi16(a, b);
333 }
334 TEST_CONSTEXPR(match_v16hi(_mm256_cmpeq_epi16((__m256i)(__v16hi){+1, -2, +3, -4, +5, -6, +7, -8, +9, -10, +11, -12, +13, -14, +15, -16}, (__m256i)(__v16hi){-10, -2, +6, -4, +5, -12, +14, -8, +9, -20, +22, -12, +26, -14, +30, -16}), 0, -1, 0, -1, -1, 0, 0, -1, -1, 0, 0, -1, 0, -1, 0, -1));
335
336 __m256i test_mm256_cmpeq_epi32(__m256i a, __m256i b) {
337 // CHECK-LABEL: test_mm256_cmpeq_epi32
338 // CHECK: icmp eq <8 x i32>
339 return _mm256_cmpeq_epi32(a, b);
340 }
341 TEST_CONSTEXPR(match_v8si(_mm256_cmpeq_epi32((__m256i)(__v8si){+1, -2, +3, -4, +5, -6, +7, -8}, (__m256i)(__v8si){-10, -2, +6, -4, +5, -12, +14, -8}), 0, -1, 0, -1, -1, 0, 0, -1));
342
343 __m256i test_mm256_cmpeq_epi64(__m256i a, __m256i b) {
344 // CHECK-LABEL: test_mm256_cmpeq_epi64
345 // CHECK: icmp eq <4 x i64>
346 return _mm256_cmpeq_epi64(a, b);
347 }
348 TEST_CONSTEXPR(match_v4di(_mm256_cmpeq_epi64((__m256i)(__v4di){+1, -2, +3, -4}, (__m256i)(__v4di){-10, -2, +6, -4}), 0, -1, 0, -1));
349
350 __m256i test_mm256_cmpgt_epi8(__m256i a, __m256i b) {
351 // CHECK-LABEL: test_mm256_cmpgt_epi8
352 // CHECK: icmp sgt <32 x i8>
353 return _mm256_cmpgt_epi8(a, b);
354 }
355 TEST_CONSTEXPR(match_v32qi(_mm256_cmpgt_epi8(
356 (__m256i)(__v32qs){1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, -1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16},
357 (__m256i)(__v32qs){10, -2, 6, -5, 30, -7, 8, -1, 20, -3, 12, -8, 25, -10, 9, -2, -10, 2, -6, 5, -30, 7, -8, 1, -20, 3, -12, 8, -25, 10, -9, 2}),
358 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1));
359
360 __m256i test_mm256_cmpgt_epi16(__m256i a, __m256i b) {
361 // CHECK-LABEL: test_mm256_cmpgt_epi16
362 // CHECK: icmp sgt <16 x i16>
363 return _mm256_cmpgt_epi16(a, b);
364 }
365 TEST_CONSTEXPR(match_v16hi(_mm256_cmpgt_epi16((__m256i)(__v16hi){+1, -2, +3, -4, +5, -6, +7, -8, +1, -2, +3, -4, +5, -6, +7, -8}, (__m256i)(__v16hi){-10, -2, +6, -5, +30, -7, +8, -1, -10, -2, +6, -5, +30, -7, +8, -1}), -1, 0, 0, -1, 0, -1, 0, 0, -1, 0, 0, -1, 0, -1, 0, 0));
366
367 __m256i test_mm256_cmpgt_epi32(__m256i a, __m256i b) {
368 // CHECK-LABEL: test_mm256_cmpgt_epi32
369 // CHECK: icmp sgt <8 x i32>
370 return _mm256_cmpgt_epi32(a, b);
371 }
372 TEST_CONSTEXPR(match_v8si(_mm256_cmpgt_epi32((__m256i)(__v8si){+1, -2, +3, -4, +5, -6, +7, -8}, (__m256i)(__v8si){-10, -2, +6, -5, +30, -7, +8, -1}), -1, 0, 0, -1, 0, -1, 0, 0));
373
374 __m256i test_mm256_cmpgt_epi64(__m256i a, __m256i b) {
375 // CHECK-LABEL: test_mm256_cmpgt_epi64
376 // CHECK: icmp sgt <4 x i64>
377 return _mm256_cmpgt_epi64(a, b);
378 }
379 TEST_CONSTEXPR(match_v4di(_mm256_cmpgt_epi64((__m256i)(__v4di){+1, -2, +3, -4}, (__m256i)(__v4di){-10, -2, +6, -5}), -1, 0, 0, -1));
380
381 __m256i test_mm256_cvtepi8_epi16(__m128i a) {
382 // CHECK-LABEL: test_mm256_cvtepi8_epi16
383 // CHECK: sext <16 x i8> %{{.*}} to <16 x i16>
384 return _mm256_cvtepi8_epi16(a);
385 }
386 TEST_CONSTEXPR(match_v16hi(_mm256_cvtepi8_epi16(_mm_setr_epi8(-3, 2, -1, 0, 1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12)), -3, 2, -1, 0, 1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12));
387
388 __m256i test_mm256_cvtepi8_epi32(__m128i a) {
389 // CHECK-LABEL: test_mm256_cvtepi8_epi32
390 // CHECK: shufflevector <16 x i8> %{{.*}}, <16 x i8> %{{.*}}, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
391 // CHECK: sext <8 x i8> %{{.*}} to <8 x i32>
392 return _mm256_cvtepi8_epi32(a);
393 }
394 TEST_CONSTEXPR(match_v8si(_mm256_cvtepi8_epi32(_mm_setr_epi8(-3, 2, -1, 0, 1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12)), -3, 2, -1, 0, 1, -2, 3, -4));
395
396 __m256i test_mm256_cvtepi8_epi64(__m128i a) {
397 // CHECK-LABEL: test_mm256_cvtepi8_epi64
398 // CHECK: shufflevector <16 x i8> %{{.*}}, <16 x i8> %{{.*}}, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
399 // CHECK: sext <4 x i8> %{{.*}} to <4 x i64>
400 return _mm256_cvtepi8_epi64(a);
401 }
402 TEST_CONSTEXPR(match_v4di(_mm256_cvtepi8_epi64(_mm_setr_epi8(-3, 2, -1, 0, 1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12)), -3, 2, -1, 0));
403
404 __m256i test_mm256_cvtepi16_epi32(__m128i a) {
405 // CHECK-LABEL: test_mm256_cvtepi16_epi32
406 // CHECK: sext <8 x i16> %{{.*}} to <8 x i32>
407 return _mm256_cvtepi16_epi32(a);
408 }
409 TEST_CONSTEXPR(match_v8si(_mm256_cvtepi16_epi32(_mm_setr_epi16(-300, 2, -1, 0, 1, -2, 3, -4)), -300, 2, -1, 0, 1, -2, 3, -4));
410
411 __m256i test_mm256_cvtepi16_epi64(__m128i a) {
412 // CHECK-LABEL: test_mm256_cvtepi16_epi64
413 // CHECK: shufflevector <8 x i16> %{{.*}}, <8 x i16> %{{.*}}, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
414 // CHECK: sext <4 x i16> %{{.*}} to <4 x i64>
415 return _mm256_cvtepi16_epi64(a);
416 }
417 TEST_CONSTEXPR(match_v4di(_mm256_cvtepi16_epi64(_mm_setr_epi16(-300, 2, -1, 0, 1, -2, 3, -4)), -300, 2, -1, 0));
418
419 __m256i test_mm256_cvtepi32_epi64(__m128i a) {
420 // CHECK-LABEL: test_mm256_cvtepi32_epi64
421 // CHECK: sext <4 x i32> %{{.*}} to <4 x i64>
422 return _mm256_cvtepi32_epi64(a);
423 }
424 TEST_CONSTEXPR(match_v4di(_mm256_cvtepi32_epi64(_mm_setr_epi32(-70000, 2, -1, 0)), -70000, 2, -1, 0));
425
426 __m256i test_mm256_cvtepu8_epi16(__m128i a) {
427 // CHECK-LABEL: test_mm256_cvtepu8_epi16
428 // CHECK: zext <16 x i8> %{{.*}} to <16 x i16>
429 return _mm256_cvtepu8_epi16(a);
430 }
431 TEST_CONSTEXPR(match_v16hi(_mm256_cvtepu8_epi16(_mm_setr_epi8(-3, 2, -1, 0, 1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12)), 253, 2, 255, 0, 1, 254, 3, 252, 5, 250, 7, 248, 9, 246, 11, 244));
432
433 __m256i test_mm256_cvtepu8_epi32(__m128i a) {
434 // CHECK-LABEL: test_mm256_cvtepu8_epi32
435 // CHECK: shufflevector <16 x i8> %{{.*}}, <16 x i8> %{{.*}}, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
436 // CHECK: zext <8 x i8> %{{.*}} to <8 x i32>
437 return _mm256_cvtepu8_epi32(a);
438 }
439 TEST_CONSTEXPR(match_v8si(_mm256_cvtepu8_epi32(_mm_setr_epi8(-3, 2, -1, 0, 1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12)), 253, 2, 255, 0, 1, 254, 3, 252));
440
441 __m256i test_mm256_cvtepu8_epi64(__m128i a) {
442 // CHECK-LABEL: test_mm256_cvtepu8_epi64
443 // CHECK: shufflevector <16 x i8> %{{.*}}, <16 x i8> %{{.*}}, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
444 // CHECK: zext <4 x i8> %{{.*}} to <4 x i64>
445 return _mm256_cvtepu8_epi64(a);
446 }
447 TEST_CONSTEXPR(match_v4di(_mm256_cvtepu8_epi64(_mm_setr_epi8(-3, 2, -1, 0, 1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12)), 253, 2, 255, 0));
448
449 __m256i test_mm256_cvtepu16_epi32(__m128i a) {
450 // CHECK-LABEL: test_mm256_cvtepu16_epi32
451 // CHECK: zext <8 x i16> {{.*}} to <8 x i32>
452 return _mm256_cvtepu16_epi32(a);
453 }
454 TEST_CONSTEXPR(match_v8si(_mm256_cvtepu16_epi32(_mm_setr_epi16(-300, 2, -1, 0, 1, -2, 3, -4)), 65236, 2, 65535, 0, 1, 65534, 3, 65532));
455
456 __m256i test_mm256_cvtepu16_epi64(__m128i a) {
457 // CHECK-LABEL: test_mm256_cvtepu16_epi64
458 // CHECK: shufflevector <8 x i16> %{{.*}}, <8 x i16> %{{.*}}, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
459 // CHECK: zext <4 x i16> %{{.*}} to <4 x i64>
460 return _mm256_cvtepu16_epi64(a);
461 }
462 TEST_CONSTEXPR(match_v4di(_mm256_cvtepu16_epi64(_mm_setr_epi16(-300, 2, -1, 0, 1, -2, 3, -4)), 65236, 2, 65535, 0));
463
464 __m256i test_mm256_cvtepu32_epi64(__m128i a) {
465 // CHECK-LABEL: test_mm256_cvtepu32_epi64
466 // CHECK: zext <4 x i32> %{{.*}} to <4 x i64>
467 return _mm256_cvtepu32_epi64(a);
468 }
469 TEST_CONSTEXPR(match_v4di(_mm256_cvtepu32_epi64(_mm_setr_epi32(-70000, 2, -1, 0)), 4294897296, 2, 4294967295, 0));
470
471 __m128i test0_mm256_extracti128_si256_0(__m256i a) {
472 // CHECK-LABEL: test0_mm256_extracti128_si256
473 // CHECK: shufflevector <4 x i64> %{{.*}}, <4 x i64> poison, <2 x i32> <i32 0, i32 1>
474 return _mm256_extracti128_si256(a, 0);
475 }
476 TEST_CONSTEXPR(match_m128i(_mm256_extracti128_si256(((__m256i){1ULL, 2ULL, 3ULL, 4ULL}), 0),1ULL, 2ULL));
477
478 __m128i test1_mm256_extracti128_si256_1(__m256i a) {
479 // CHECK-LABEL: test1_mm256_extracti128_si256
480 // CHECK: shufflevector <4 x i64> %{{.*}}, <4 x i64> poison, <2 x i32> <i32 2, i32 3>
481 return _mm256_extracti128_si256(a, 1);
482 }
483
484 // Immediate should be truncated to one bit.
485 __m128i test2_mm256_extracti128_si256(__m256i a) {
486 // CHECK-LABEL: test2_mm256_extracti128_si256
487 // CHECK: shufflevector <4 x i64> %{{.*}}, <4 x i64> poison, <2 x i32> <i32 0, i32 1>
488 return _mm256_extracti128_si256(a, 0);
489 }
490
491 __m256i test_mm256_hadd_epi16(__m256i a, __m256i b) {
492 // CHECK-LABEL: test_mm256_hadd_epi16
493 // CHECK: call <16 x i16> @llvm.x86.avx2.phadd.w(<16 x i16> %{{.*}}, <16 x i16> %{{.*}})
494 return _mm256_hadd_epi16(a, b);
495 }
496 TEST_CONSTEXPR(match_v16hi(_mm256_hadd_epi16(
497 (__m256i)(__v16hi){1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16},
498 (__m256i)(__v16hi){17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32}),
499 3,7,11,15,35,39,43,47,19,23,27,31,51,55,59,63));
500
501 __m256i test_mm256_hadd_epi32(__m256i a, __m256i b) {
502 // CHECK-LABEL: test_mm256_hadd_epi32
503 // CHECK: call <8 x i32> @llvm.x86.avx2.phadd.d(<8 x i32> %{{.*}}, <8 x i32> %{{.*}})
504 return _mm256_hadd_epi32(a, b);
505 }
506 TEST_CONSTEXPR(match_v8si(_mm256_hadd_epi32(
507 (__m256i)(__v8si){10, 20, 30, 40, 50, 60, 70, 80},
508 (__m256i)(__v8si){5, 15, 25, 35, 45, 55, 65, 75}),
509 30,70,20,60,110,150,100,140));
510
511 __m256i test_mm256_hadds_epi16(__m256i a, __m256i b) {
512 // CHECK-LABEL: test_mm256_hadds_epi16
513 // CHECK:call <16 x i16> @llvm.x86.avx2.phadd.sw(<16 x i16> %{{.*}}, <16 x i16> %{{.*}})
514 return _mm256_hadds_epi16(a, b);
515 }
516 TEST_CONSTEXPR(match_v16hi( _mm256_hadds_epi16(
517 (__m256i)(__v16hi){32767, 32767, 1,2,3,4,5,6,7,8,9,10,11,12,13,14},
518 (__m256i)(__v16hi){19,20,21,22,23,24,25,26,27,28,29,30,31,32, 32767, 5}),
519 32767, 3,7,11, 39,43,47,51,15,19,23,27, 55,59,63, 32767));
520
521 __m256i test_mm256_hsub_epi16(__m256i a, __m256i b) {
522 // CHECK-LABEL: test_mm256_hsub_epi16
523 // CHECK: call <16 x i16> @llvm.x86.avx2.phsub.w(<16 x i16> %{{.*}}, <16 x i16> %{{.*}})
524 return _mm256_hsub_epi16(a, b);
525 }
526 TEST_CONSTEXPR(match_v16hi(_mm256_hsub_epi16(
527 (__m256i)(__v16hi){2,1,1,2,5,3,3,5,7,4,4,7,9,5,5,9},
528 (__m256i)(__v16hi){10,5,5,10,12,6,6,12,21,14,14,21,24,16,16,24}),
529 1,-1,2,-2,5,-5,6,-6,3,-3,4,-4, 7,-7,8,-8));
530
531 __m256i test_mm256_hsub_epi32(__m256i a, __m256i b) {
532 // CHECK-LABEL: test_mm256_hsub_epi32
533 // CHECK: call <8 x i32> @llvm.x86.avx2.phsub.d(<8 x i32> %{{.*}}, <8 x i32> %{{.*}})
534 return _mm256_hsub_epi32(a, b);
535 }
536 TEST_CONSTEXPR(match_v8si(_mm256_hsub_epi32(
537 (__m256i)(__v8si){10, 20, 30,50,60,90,100,140},
538 (__m256i)(__v8si){200,150,260,200,420,350,800,720}),
539 -10,-20,50,60, -30,-40, 70,80));
540
541 __m256i test_mm256_hsubs_epi16(__m256i a, __m256i b) {
542 // CHECK-LABEL: test_mm256_hsubs_epi16
543 // CHECK:call <16 x i16> @llvm.x86.avx2.phsub.sw(<16 x i16> %{{.*}}, <16 x i16> %{{.*}})
544 return _mm256_hsubs_epi16(a, b);
545 }
546 TEST_CONSTEXPR(match_v16hi(_mm256_hsubs_epi16(
547 (__m256i)(__v16hi){32726, -100, 3, 2, 6, 4, 8, 5,15,10 ,21, 14, 27, 18, 100, 90},
548 (__m256i)(__v16hi){40, 20, 100, 70, 200,150, 100,40, 1000,900,300,150, 500,300, 1, 1}),
549 32767, 1, 2, 3, 20, 30, 50, 60, 5, 7, 9, 10, 100, 150, 200, 0));
550
551 __m128i test_mm_i32gather_epi32(int const *b, __m128i c) {
552 // CHECK-LABEL: test_mm_i32gather_epi32
553 // CHECK: call <4 x i32> @llvm.x86.avx2.gather.d.d(<4 x i32> %{{.*}}, ptr %{{.*}}, <4 x i32> %{{.*}}, <4 x i32> %{{.*}}, i8 2)
554 return _mm_i32gather_epi32(b, c, 2);
555 }
556
557 __m128i test_mm_mask_i32gather_epi32(__m128i a, int const *b, __m128i c, __m128i d) {
558 // CHECK-LABEL: test_mm_mask_i32gather_epi32
559 // CHECK: call <4 x i32> @llvm.x86.avx2.gather.d.d(<4 x i32> %{{.*}}, ptr %{{.*}}, <4 x i32> %{{.*}}, <4 x i32> %{{.*}}, i8 2)
560 return _mm_mask_i32gather_epi32(a, b, c, d, 2);
561 }
562
563 __m256i test_mm256_i32gather_epi32(int const *b, __m256i c) {
564 // CHECK-LABEL: test_mm256_i32gather_epi32
565 // CHECK: call <8 x i32> @llvm.x86.avx2.gather.d.d.256(<8 x i32> %{{.*}}, ptr %{{.*}}, <8 x i32> %{{.*}}, <8 x i32> %{{.*}}, i8 2)
566 return _mm256_i32gather_epi32(b, c, 2);
567 }
568
569 __m256i test_mm256_mask_i32gather_epi32(__m256i a, int const *b, __m256i c, __m256i d) {
570 // CHECK-LABEL: test_mm256_mask_i32gather_epi32
571 // CHECK: call <8 x i32> @llvm.x86.avx2.gather.d.d.256(<8 x i32> %{{.*}}, ptr %{{.*}}, <8 x i32> %{{.*}}, <8 x i32> %{{.*}}, i8 2)
572 return _mm256_mask_i32gather_epi32(a, b, c, d, 2);
573 }
574
575 __m128i test_mm_i32gather_epi64(long long const *b, __m128i c) {
576 // CHECK-LABEL: test_mm_i32gather_epi64
577 // CHECK: call {{.*}}<2 x i64> @llvm.x86.avx2.gather.d.q(<2 x i64> zeroinitializer, ptr %{{.*}}, <4 x i32> %{{.*}}, <2 x i64> %{{.*}}, i8 2)
578 return _mm_i32gather_epi64(b, c, 2);
579 }
580
581 __m128i test_mm_mask_i32gather_epi64(__m128i a, long long const *b, __m128i c, __m128i d) {
582 // CHECK-LABEL: test_mm_mask_i32gather_epi64
583 // CHECK: call {{.*}}<2 x i64> @llvm.x86.avx2.gather.d.q(<2 x i64> %{{.*}}, ptr %{{.*}}, <4 x i32> %{{.*}}, <2 x i64> %{{.*}}, i8 2)
584 return _mm_mask_i32gather_epi64(a, b, c, d, 2);
585 }
586
587 __m256i test_mm256_i32gather_epi64(long long const *b, __m128i c) {
588 // X64-LABEL: test_mm256_i32gather_epi64
589 // X64: call {{.*}}<4 x i64> @llvm.x86.avx2.gather.d.q.256(<4 x i64> zeroinitializer, ptr %{{.*}}, <4 x i32> %{{.*}}, <4 x i64> %{{.*}}, i8 2)
590 //
591 // X86-LABEL: test_mm256_i32gather_epi64
592 // X86: call {{.*}}<4 x i64> @llvm.x86.avx2.gather.d.q.256(<4 x i64> %{{.*}}, ptr %{{.*}}, <4 x i32> %{{.*}}, <4 x i64> %{{.*}}, i8 2)
593 return _mm256_i32gather_epi64(b, c, 2);
594 }
595
596 __m256i test_mm256_mask_i32gather_epi64(__m256i a, long long const *b, __m128i c, __m256i d) {
597 // CHECK-LABEL: test_mm256_mask_i32gather_epi64
598 // CHECK: call {{.*}}<4 x i64> @llvm.x86.avx2.gather.d.q.256(<4 x i64> %{{.*}}, ptr %{{.*}}, <4 x i32> %{{.*}}, <4 x i64> %{{.*}}, i8 2)
599 return _mm256_mask_i32gather_epi64(a, b, c, d, 2);
600 }
601
602 __m128d test_mm_i32gather_pd(double const *b, __m128i c) {
603 // X64-LABEL: test_mm_i32gather_pd
604 // X64: [[CMP:%.*]] = fcmp oeq <2 x double>
605 // X64-NEXT: [[SEXT:%.*]] = sext <2 x i1> [[CMP]] to <2 x i64>
606 // X64-NEXT: [[BC:%.*]] = bitcast <2 x i64> [[SEXT]] to <2 x double>
607 // X64: call <2 x double> @llvm.x86.avx2.gather.d.pd(<2 x double> zeroinitializer, ptr %{{.*}}, <4 x i32> %{{.*}}, <2 x double> %{{.*}}, i8 2)
608 //
609 // X86-LABEL: test_mm_i32gather_pd
610 // X86: [[CMP:%.*]] = fcmp oeq <2 x double>
611 // X86-NEXT: [[SEXT:%.*]] = sext <2 x i1> [[CMP]] to <2 x i64>
612 // X86-NEXT: [[BC:%.*]] = bitcast <2 x i64> [[SEXT]] to <2 x double>
613 // X86: call <2 x double> @llvm.x86.avx2.gather.d.pd(<2 x double> %{{.*}}, ptr %{{.*}}, <4 x i32> %{{.*}}, <2 x double> %{{.*}}, i8 2)
614 return _mm_i32gather_pd(b, c, 2);
615 }
616
617 __m128d test_mm_mask_i32gather_pd(__m128d a, double const *b, __m128i c, __m128d d) {
618 // CHECK-LABEL: test_mm_mask_i32gather_pd
619 // CHECK: call <2 x double> @llvm.x86.avx2.gather.d.pd(<2 x double> %{{.*}}, ptr %{{.*}}, <4 x i32> %{{.*}}, <2 x double> %{{.*}}, i8 2)
620 return _mm_mask_i32gather_pd(a, b, c, d, 2);
621 }
622
623 __m256d test_mm256_i32gather_pd(double const *b, __m128i c) {
624 // X64-LABEL: test_mm256_i32gather_pd
625 // X64: [[CMP:%.*]] = fcmp oeq <4 x double>
626 // X64-NEXT: [[SEXT:%.*]] = sext <4 x i1> [[CMP]] to <4 x i64>
627 // X64-NEXT: [[BC:%.*]] = bitcast <4 x i64> [[SEXT]] to <4 x double>
628 // X64: call <4 x double> @llvm.x86.avx2.gather.d.pd.256(<4 x double> zeroinitializer, ptr %{{.*}}, <4 x i32> %{{.*}}, <4 x double> %{{.*}}, i8 2)
629 //
630 // X86-LABEL: test_mm256_i32gather_pd
631 // X86: [[CMP:%.*]] = fcmp oeq <4 x double>
632 // X86-NEXT: [[SEXT:%.*]] = sext <4 x i1> [[CMP]] to <4 x i64>
633 // X86-NEXT: [[BC:%.*]] = bitcast <4 x i64> [[SEXT]] to <4 x double>
634 // X86: call <4 x double> @llvm.x86.avx2.gather.d.pd.256(<4 x double> %{{.*}}, ptr %{{.*}}, <4 x i32> %{{.*}}, <4 x double> %{{.*}}, i8 2)
635 return _mm256_i32gather_pd(b, c, 2);
636 }
637
638 __m256d test_mm256_mask_i32gather_pd(__m256d a, double const *b, __m128i c, __m256d d) {
639 // CHECK-LABEL: test_mm256_mask_i32gather_pd
640 // CHECK: call <4 x double> @llvm.x86.avx2.gather.d.pd.256(<4 x double> %{{.*}}, ptr %{{.*}}, <4 x i32> %{{.*}}, <4 x double> %{{.*}}, i8 2)
641 return _mm256_mask_i32gather_pd(a, b, c, d, 2);
642 }
643
644 __m128 test_mm_i32gather_ps(float const *b, __m128i c) {
645 // X64-LABEL: test_mm_i32gather_ps
646 // X64: [[CMP:%.*]] = fcmp oeq <4 x float>
647 // X64-NEXT: [[SEXT:%.*]] = sext <4 x i1> [[CMP]] to <4 x i32>
648 // X64-NEXT: [[BC:%.*]] = bitcast <4 x i32> [[SEXT]] to <4 x float>
649 // X64: call <4 x float> @llvm.x86.avx2.gather.d.ps(<4 x float> zeroinitializer, ptr %{{.*}}, <4 x i32> %{{.*}}, <4 x float> %{{.*}}, i8 2)
650 //
651 // X86-LABEL: test_mm_i32gather_ps
652 // X86: [[CMP:%.*]] = fcmp oeq <4 x float>
653 // X86-NEXT: [[SEXT:%.*]] = sext <4 x i1> [[CMP]] to <4 x i32>
654 // X86-NEXT: [[BC:%.*]] = bitcast <4 x i32> [[SEXT]] to <4 x float>
655 // X86: call <4 x float> @llvm.x86.avx2.gather.d.ps(<4 x float> %{{.*}}, ptr %{{.*}}, <4 x i32> %{{.*}}, <4 x float> %{{.*}}, i8 2)
656 return _mm_i32gather_ps(b, c, 2);
657 }
658
659 __m128 test_mm_mask_i32gather_ps(__m128 a, float const *b, __m128i c, __m128 d) {
660 // CHECK-LABEL: test_mm_mask_i32gather_ps
661 // CHECK: call <4 x float> @llvm.x86.avx2.gather.d.ps(<4 x float> %{{.*}}, ptr %{{.*}}, <4 x i32> %{{.*}}, <4 x float> %{{.*}}, i8 2)
662 return _mm_mask_i32gather_ps(a, b, c, d, 2);
663 }
664
665 __m256 test_mm256_i32gather_ps(float const *b, __m256i c) {
666 // X64-LABEL: test_mm256_i32gather_ps
667 // X64: [[CMP:%.*]] = fcmp oeq <8 x float>
668 // X64-NEXT: [[SEXT:%.*]] = sext <8 x i1> [[CMP]] to <8 x i32>
669 // X64-NEXT: [[BC:%.*]] = bitcast <8 x i32> [[SEXT]] to <8 x float>
670 // X64: call <8 x float> @llvm.x86.avx2.gather.d.ps.256(<8 x float> zeroinitializer, ptr %{{.*}}, <8 x i32> %{{.*}}, <8 x float> %{{.*}}, i8 2)
671 //
672 // X86-LABEL: test_mm256_i32gather_ps
673 // X86: [[CMP:%.*]] = fcmp oeq <8 x float>
674 // X86-NEXT: [[SEXT:%.*]] = sext <8 x i1> [[CMP]] to <8 x i32>
675 // X86-NEXT: [[BC:%.*]] = bitcast <8 x i32> [[SEXT]] to <8 x float>
676 // X86: call <8 x float> @llvm.x86.avx2.gather.d.ps.256(<8 x float> %{{.*}}, ptr %{{.*}}, <8 x i32> %{{.*}}, <8 x float> %{{.*}}, i8 2)
677 return _mm256_i32gather_ps(b, c, 2);
678 }
679
680 __m256 test_mm256_mask_i32gather_ps(__m256 a, float const *b, __m256i c, __m256 d) {
681 // CHECK-LABEL: test_mm256_mask_i32gather_ps
682 // CHECK: call <8 x float> @llvm.x86.avx2.gather.d.ps.256(<8 x float> %{{.*}}, ptr %{{.*}}, <8 x i32> %{{.*}}, <8 x float> %{{.*}}, i8 2)
683 return _mm256_mask_i32gather_ps(a, b, c, d, 2);
684 }
685
686 __m128i test_mm_i64gather_epi32(int const *b, __m128i c) {
687 // CHECK-LABEL: test_mm_i64gather_epi32
688 // CHECK: call <4 x i32> @llvm.x86.avx2.gather.q.d(<4 x i32> %{{.*}}, ptr %{{.*}}, <2 x i64> %{{.*}}, <4 x i32> %{{.*}}, i8 2)
689 return _mm_i64gather_epi32(b, c, 2);
690 }
691
692 __m128i test_mm_mask_i64gather_epi32(__m128i a, int const *b, __m128i c, __m128i d) {
693 // CHECK-LABEL: test_mm_mask_i64gather_epi32
694 // CHECK: call <4 x i32> @llvm.x86.avx2.gather.q.d(<4 x i32> %{{.*}}, ptr %{{.*}}, <2 x i64> %{{.*}}, <4 x i32> %{{.*}}, i8 2)
695 return _mm_mask_i64gather_epi32(a, b, c, d, 2);
696 }
697
698 __m128i test_mm256_i64gather_epi32(int const *b, __m256i c) {
699 // CHECK-LABEL: test_mm256_i64gather_epi32
700 // CHECK: call <4 x i32> @llvm.x86.avx2.gather.q.d.256(<4 x i32> %{{.*}}, ptr %{{.*}}, <4 x i64> %{{.*}}, <4 x i32> %{{.*}}, i8 2)
701 return _mm256_i64gather_epi32(b, c, 2);
702 }
703
704 __m128i test_mm256_mask_i64gather_epi32(__m128i a, int const *b, __m256i c, __m128i d) {
705 // CHECK-LABEL: test_mm256_mask_i64gather_epi32
706 // CHECK: call <4 x i32> @llvm.x86.avx2.gather.q.d.256(<4 x i32> %{{.*}}, ptr %{{.*}}, <4 x i64> %{{.*}}, <4 x i32> %{{.*}}, i8 2)
707 return _mm256_mask_i64gather_epi32(a, b, c, d, 2);
708 }
709
710 __m128i test_mm_i64gather_epi64(long long const *b, __m128i c) {
711 // CHECK-LABEL: test_mm_i64gather_epi64
712 // CHECK: call {{.*}}<2 x i64> @llvm.x86.avx2.gather.q.q(<2 x i64> zeroinitializer, ptr %{{.*}}, <2 x i64> %{{.*}}, <2 x i64> %{{.*}}, i8 2)
713 return _mm_i64gather_epi64(b, c, 2);
714 }
715
716 __m128i test_mm_mask_i64gather_epi64(__m128i a, long long const *b, __m128i c, __m128i d) {
717 // CHECK-LABEL: test_mm_mask_i64gather_epi64
718 // CHECK: call {{.*}}<2 x i64> @llvm.x86.avx2.gather.q.q(<2 x i64> %{{.*}}, ptr %{{.*}}, <2 x i64> %{{.*}}, <2 x i64> %{{.*}}, i8 2)
719 return _mm_mask_i64gather_epi64(a, b, c, d, 2);
720 }
721
722 __m256i test_mm256_i64gather_epi64(long long const *b, __m256i c) {
723 // X64-LABEL: test_mm256_i64gather_epi64
724 // X64: call {{.*}}<4 x i64> @llvm.x86.avx2.gather.q.q.256(<4 x i64> zeroinitializer, ptr %{{.*}}, <4 x i64> %{{.*}}, <4 x i64> %{{.*}}, i8 2)
725 //
726 // X86-LABEL: test_mm256_i64gather_epi64
727 // X86: call {{.*}}<4 x i64> @llvm.x86.avx2.gather.q.q.256(<4 x i64> %{{.*}}, ptr %{{.*}}, <4 x i64> %{{.*}}, <4 x i64> %{{.*}}, i8 2)
728 return _mm256_i64gather_epi64(b, c, 2);
729 }
730
731 __m256i test_mm256_mask_i64gather_epi64(__m256i a, long long const *b, __m256i c, __m256i d) {
732 // CHECK-LABEL: test_mm256_mask_i64gather_epi64
733 // CHECK: call {{.*}}<4 x i64> @llvm.x86.avx2.gather.q.q.256(<4 x i64> %{{.*}}, ptr %{{.*}}, <4 x i64> %{{.*}}, <4 x i64> %{{.*}}, i8 2)
734 return _mm256_mask_i64gather_epi64(a, b, c, d, 2);
735 }
736
737 __m128d test_mm_i64gather_pd(double const *b, __m128i c) {
738 // X64-LABEL: test_mm_i64gather_pd
739 // X64: [[CMP:%.*]] = fcmp oeq <2 x double>
740 // X64-NEXT: [[SEXT:%.*]] = sext <2 x i1> [[CMP]] to <2 x i64>
741 // X64-NEXT: [[BC:%.*]] = bitcast <2 x i64> [[SEXT]] to <2 x double>
742 // X64: call <2 x double> @llvm.x86.avx2.gather.q.pd(<2 x double> zeroinitializer, ptr %{{.*}}, <2 x i64> %{{.*}}, <2 x double> %{{.*}}, i8 2)
743 //
744 // X86-LABEL: test_mm_i64gather_pd
745 // X86: [[CMP:%.*]] = fcmp oeq <2 x double>
746 // X86-NEXT: [[SEXT:%.*]] = sext <2 x i1> [[CMP]] to <2 x i64>
747 // X86-NEXT: [[BC:%.*]] = bitcast <2 x i64> [[SEXT]] to <2 x double>
748 // X86: call <2 x double> @llvm.x86.avx2.gather.q.pd(<2 x double> %{{.*}}, ptr %{{.*}}, <2 x i64> %{{.*}}, <2 x double> %{{.*}}, i8 2)
749 return _mm_i64gather_pd(b, c, 2);
750 }
751
752 __m128d test_mm_mask_i64gather_pd(__m128d a, double const *b, __m128i c, __m128d d) {
753 // CHECK-LABEL: test_mm_mask_i64gather_pd
754 // CHECK: call <2 x double> @llvm.x86.avx2.gather.q.pd(<2 x double> %{{.*}}, ptr %{{.*}}, <2 x i64> %{{.*}}, <2 x double> %{{.*}}, i8 2)
755 return _mm_mask_i64gather_pd(a, b, c, d, 2);
756 }
757
758 __m256d test_mm256_i64gather_pd(double const *b, __m256i c) {
759 // X64-LABEL: test_mm256_i64gather_pd
760 // X64: fcmp oeq <4 x double> %{{.*}}, %{{.*}}
761 // X64: call <4 x double> @llvm.x86.avx2.gather.q.pd.256(<4 x double> zeroinitializer, ptr %{{.*}}, <4 x i64> %{{.*}}, <4 x double> %{{.*}}, i8 2)
762 //
763 // X86-LABEL: test_mm256_i64gather_pd
764 // X86: fcmp oeq <4 x double> %{{.*}}, %{{.*}}
765 // X86: call <4 x double> @llvm.x86.avx2.gather.q.pd.256(<4 x double> %{{.*}}, ptr %{{.*}}, <4 x i64> %{{.*}}, <4 x double> %{{.*}}, i8 2)
766 return _mm256_i64gather_pd(b, c, 2);
767 }
768
769 __m256d test_mm256_mask_i64gather_pd(__m256d a, double const *b, __m256i c, __m256d d) {
770 // CHECK-LABEL: test_mm256_mask_i64gather_pd
771 // CHECK: call <4 x double> @llvm.x86.avx2.gather.q.pd.256(<4 x double> %{{.*}}, ptr %{{.*}}, <4 x i64> %{{.*}}, <4 x double> %{{.*}}, i8 2)
772 return _mm256_mask_i64gather_pd(a, b, c, d, 2);
773 }
774
775 __m128 test_mm_i64gather_ps(float const *b, __m128i c) {
776 // X64-LABEL: test_mm_i64gather_ps
777 // X64: [[CMP:%.*]] = fcmp oeq <4 x float>
778 // X64-NEXT: [[SEXT:%.*]] = sext <4 x i1> [[CMP]] to <4 x i32>
779 // X64-NEXT: [[BC:%.*]] = bitcast <4 x i32> [[SEXT]] to <4 x float>
780 // X64: call <4 x float> @llvm.x86.avx2.gather.q.ps(<4 x float> zeroinitializer, ptr %{{.*}}, <2 x i64> %{{.*}}, <4 x float> %{{.*}}, i8 2)
781 //
782 // X86-LABEL: test_mm_i64gather_ps
783 // X86: [[CMP:%.*]] = fcmp oeq <4 x float>
784 // X86-NEXT: [[SEXT:%.*]] = sext <4 x i1> [[CMP]] to <4 x i32>
785 // X86-NEXT: [[BC:%.*]] = bitcast <4 x i32> [[SEXT]] to <4 x float>
786 // X86: call <4 x float> @llvm.x86.avx2.gather.q.ps(<4 x float> %{{.*}}, ptr %{{.*}}, <2 x i64> %{{.*}}, <4 x float> %{{.*}}, i8 2)
787 return _mm_i64gather_ps(b, c, 2);
788 }
789
790 __m128 test_mm_mask_i64gather_ps(__m128 a, float const *b, __m128i c, __m128 d) {
791 // CHECK-LABEL: test_mm_mask_i64gather_ps
792 // CHECK: call <4 x float> @llvm.x86.avx2.gather.q.ps(<4 x float> %{{.*}}, ptr %{{.*}}, <2 x i64> %{{.*}}, <4 x float> %{{.*}}, i8 2)
793 return _mm_mask_i64gather_ps(a, b, c, d, 2);
794 }
795
796 __m128 test_mm256_i64gather_ps(float const *b, __m256i c) {
797 // X64-LABEL: test_mm256_i64gather_ps
798 // X64: [[CMP:%.*]] = fcmp oeq <4 x float>
799 // X64-NEXT: [[SEXT:%.*]] = sext <4 x i1> [[CMP]] to <4 x i32>
800 // X64-NEXT: [[BC:%.*]] = bitcast <4 x i32> [[SEXT]] to <4 x float>
801 // X64: call <4 x float> @llvm.x86.avx2.gather.q.ps.256(<4 x float> zeroinitializer, ptr %{{.*}}, <4 x i64> %{{.*}}, <4 x float> %{{.*}}, i8 2)
802 //
803 // X86-LABEL: test_mm256_i64gather_ps
804 // X86: [[CMP:%.*]] = fcmp oeq <4 x float>
805 // X86-NEXT: [[SEXT:%.*]] = sext <4 x i1> [[CMP]] to <4 x i32>
806 // X86-NEXT: [[BC:%.*]] = bitcast <4 x i32> [[SEXT]] to <4 x float>
807 // X86: call <4 x float> @llvm.x86.avx2.gather.q.ps.256(<4 x float> %{{.*}}, ptr %{{.*}}, <4 x i64> %{{.*}}, <4 x float> %{{.*}}, i8 2)
808 return _mm256_i64gather_ps(b, c, 2);
809 }
810
811 __m128 test_mm256_mask_i64gather_ps(__m128 a, float const *b, __m256i c, __m128 d) {
812 // CHECK-LABEL: test_mm256_mask_i64gather_ps
813 // CHECK: call <4 x float> @llvm.x86.avx2.gather.q.ps.256(<4 x float> %{{.*}}, ptr %{{.*}}, <4 x i64> %{{.*}}, <4 x float> %{{.*}}, i8 2)
814 return _mm256_mask_i64gather_ps(a, b, c, d, 2);
815 }
816
817 __m256i test0_mm256_inserti128_si256(__m256i a, __m128i b) {
818 // CHECK-LABEL: test0_mm256_inserti128_si256
819 // CHECK: shufflevector <2 x i64> %{{.*}}, <2 x i64> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
820 // CHECK: shufflevector <4 x i64> %{{.*}}, <4 x i64> %{{.*}}, <4 x i32> <i32 4, i32 5, i32 2, i32 3>
821 return _mm256_inserti128_si256(a, b, 0);
822 }
823 TEST_CONSTEXPR(match_m256i(_mm256_inserti128_si256(((__m256i){1ULL, 2ULL, 3ULL, 4ULL}), ((__m128i){10ULL, 20ULL}), 0), 10ULL, 20ULL, 3ULL, 4ULL));
824
825 __m256i test1_mm256_inserti128_si256(__m256i a, __m128i b) {
826 // CHECK-LABEL: test1_mm256_inserti128_si256
827 // CHECK: shufflevector <2 x i64> %{{.*}}, <2 x i64> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
828 // CHECK: shufflevector <4 x i64> %{{.*}}, <4 x i64> %{{.*}}, <4 x i32> <i32 0, i32 1, i32 4, i32 5>
829 return _mm256_inserti128_si256(a, b, 1);
830 }
831
832 // Immediate should be truncated to one bit.
833 __m256i test2_mm256_inserti128_si256(__m256i a, __m128i b) {
834 // CHECK-LABEL: test2_mm256_inserti128_si256
835 // CHECK: shufflevector <2 x i64> %{{.*}}, <2 x i64> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
836 // CHECK: shufflevector <4 x i64> %{{.*}}, <4 x i64> %{{.*}}, <4 x i32> <i32 4, i32 5, i32 2, i32 3>
837 return _mm256_inserti128_si256(a, b, 0);
838 }
839
840 __m256i test_mm256_madd_epi16(__m256i a, __m256i b) {
841 // CHECK-LABEL: test_mm256_madd_epi16
842 // CHECK: call <8 x i32> @llvm.x86.avx2.pmadd.wd(<16 x i16> %{{.*}}, <16 x i16> %{{.*}})
843 return _mm256_madd_epi16(a, b);
844 }
845 TEST_CONSTEXPR(match_v8si(_mm256_madd_epi16((__m256i)(__v16hi){1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}, (__m256i)(__v16hi){10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160}), 50, 250, 610, 1130, 1810, 2650, 3650, 4810));
846
847 __m256i test_mm256_maddubs_epi16(__m256i a, __m256i b) {
848 // CHECK-LABEL: test_mm256_maddubs_epi16
849 // CHECK: call <16 x i16> @llvm.x86.avx2.pmadd.ub.sw(<32 x i8> %{{.*}}, <32 x i8> %{{.*}})
850 return _mm256_maddubs_epi16(a, b);
851 }
852 TEST_CONSTEXPR(match_v16hi(_mm256_maddubs_epi16((__m256i)(__v32qi){1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7,8}, (__m256i)(__v32qs){2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, -1, -1, -2, -2, -3, -3, -4, -4, -5, -5, -6, -6, -7, -7, -8, -8}), 5, 18, 39, 68, 15, 42, 77, 120, -3, -14, -33, -60, -15, -42, -77, -120));
853
854 __m128i test_mm_maskload_epi32(int const *a, __m128i m) {
855 // CHECK-LABEL: test_mm_maskload_epi32
856 // CHECK: call <4 x i32> @llvm.x86.avx2.maskload.d(ptr %{{.*}}, <4 x i32> %{{.*}})
857 return _mm_maskload_epi32(a, m);
858 }
859
860 __m256i test_mm256_maskload_epi32(int const *a, __m256i m) {
861 // CHECK-LABEL: test_mm256_maskload_epi32
862 // CHECK: call <8 x i32> @llvm.x86.avx2.maskload.d.256(ptr %{{.*}}, <8 x i32> %{{.*}})
863 return _mm256_maskload_epi32(a, m);
864 }
865
866 __m128i test_mm_maskload_epi64(long long const *a, __m128i m) {
867 // CHECK-LABEL: test_mm_maskload_epi64
868 // CHECK: call {{.*}}<2 x i64> @llvm.x86.avx2.maskload.q(ptr %{{.*}}, <2 x i64> %{{.*}})
869 return _mm_maskload_epi64(a, m);
870 }
871
872 __m256i test_mm256_maskload_epi64(long long const *a, __m256i m) {
873 // CHECK-LABEL: test_mm256_maskload_epi64
874 // CHECK: call {{.*}}<4 x i64> @llvm.x86.avx2.maskload.q.256(ptr %{{.*}}, <4 x i64> %{{.*}})
875 return _mm256_maskload_epi64(a, m);
876 }
877
878 void test_mm_maskstore_epi32(int *a, __m128i m, __m128i b) {
879 // CHECK-LABEL: test_mm_maskstore_epi32
880 // CHECK: call void @llvm.x86.avx2.maskstore.d(ptr %{{.*}}, <4 x i32> %{{.*}}, <4 x i32> %{{.*}})
881 _mm_maskstore_epi32(a, m, b);
882 }
883
884 void test_mm256_maskstore_epi32(int *a, __m256i m, __m256i b) {
885 // CHECK-LABEL: test_mm256_maskstore_epi32
886 // CHECK: call void @llvm.x86.avx2.maskstore.d.256(ptr %{{.*}}, <8 x i32> %{{.*}}, <8 x i32> %{{.*}})
887 _mm256_maskstore_epi32(a, m, b);
888 }
889
890 void test_mm_maskstore_epi64(long long *a, __m128i m, __m128i b) {
891 // CHECK-LABEL: test_mm_maskstore_epi64
892 // CHECK: call void @llvm.x86.avx2.maskstore.q(ptr %{{.*}}, <2 x i64> %{{.*}}, <2 x i64> %{{.*}})
893 _mm_maskstore_epi64(a, m, b);
894 }
895
896 void test_mm256_maskstore_epi64(long long *a, __m256i m, __m256i b) {
897 // CHECK-LABEL: test_mm256_maskstore_epi64
898 // CHECK: call void @llvm.x86.avx2.maskstore.q.256(ptr %{{.*}}, <4 x i64> %{{.*}}, <4 x i64> %{{.*}})
899 _mm256_maskstore_epi64(a, m, b);
900 }
901
902 __m256i test_mm256_max_epi8(__m256i a, __m256i b) {
903 // CHECK-LABEL: test_mm256_max_epi8
904 // CHECK: call <32 x i8> @llvm.smax.v32i8(<32 x i8> %{{.*}}, <32 x i8> %{{.*}})
905 return _mm256_max_epi8(a, b);
906 }
907
908 TEST_CONSTEXPR(match_v32qi(_mm256_max_epi8((__m256i)(__v32qs){+1, -2, +3, -4, +5, -6, +7, -8, +9, -10, +11, -12, +13, -14, +15, -16, +17, -18, +19, -20, +21, -22, +23, -24, +25, -26, +27, -28, +29, -30, +31, -32}, (__m256i)(__v32qs){-1, +2, -3, +4, -5, +6, -7, +8, -9, +10, -11, +12, -13, +14, -15, +16, -17, +18, -19, +20, -21, +22, -23, +24, -25, +26, -27, +28, -29, +30, -31, +32}), +1, +2, +3, +4, +5, +6, +7, +8, +9, +10, +11, +12, +13, +14, +15, +16, +17, +18, +19, +20, +21, +22, +23, +24, +25, +26, +27, +28, +29, +30, +31, +32));
909
910 __m256i test_mm256_max_epi16(__m256i a, __m256i b) {
911 // CHECK-LABEL: test_mm256_max_epi16
912 // CHECK: call <16 x i16> @llvm.smax.v16i16(<16 x i16> %{{.*}}, <16 x i16> %{{.*}})
913 return _mm256_max_epi16(a, b);
914 }
915
916 TEST_CONSTEXPR(match_v16hi(_mm256_max_epi16((__m256i)(__v16hi){+1, -2, +3, -4, +5, -6, +7, -8, +9, -10, +11, -12, +13, -14, +15, -16}, (__m256i)(__v16hi){-1, +2, -3, +4, -5, +6, -7, +8, -9, +10, -11, +12, -13, +14, -15, +16}), +1, +2, +3, +4, +5, +6, +7, +8, +9, +10, +11, +12, +13, +14, +15, +16));
917
918 __m256i test_mm256_max_epi32(__m256i a, __m256i b) {
919 // CHECK-LABEL: test_mm256_max_epi32
920 // CHECK: call <8 x i32> @llvm.smax.v8i32(<8 x i32> %{{.*}}, <8 x i32> %{{.*}})
921 return _mm256_max_epi32(a, b);
922 }
923
924 TEST_CONSTEXPR(match_v8si(_mm256_max_epi32((__m256i)(__v8si){+1, -2, +3, -4, +5, -6, +7, -8}, (__m256i)(__v8si){-1, +2, -3, +4, -5, +6, -7, +8}), +1, +2, +3, +4, +5, +6, +7, +8));
925
926 __m256i test_mm256_max_epu8(__m256i a, __m256i b) {
927 // CHECK-LABEL: test_mm256_max_epu8
928 // CHECK: call <32 x i8> @llvm.umax.v32i8(<32 x i8> %{{.*}}, <32 x i8> %{{.*}})
929 return _mm256_max_epu8(a, b);
930 }
931
932 TEST_CONSTEXPR(match_v32qu(_mm256_max_epu8((__m256i)(__v32qu){1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32}, (__m256i)(__v32qu){0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31}), 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32));
933
934 __m256i test_mm256_max_epu16(__m256i a, __m256i b) {
935 // CHECK-LABEL: test_mm256_max_epu16
936 // CHECK: call <16 x i16> @llvm.umax.v16i16(<16 x i16> %{{.*}}, <16 x i16> %{{.*}})
937 return _mm256_max_epu16(a, b);
938 }
939
940 TEST_CONSTEXPR(match_v16hu(_mm256_max_epu16((__m256i)(__v16hu){1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}, (__m256i)(__v16hu){0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}), 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16));
941
942 __m256i test_mm256_max_epu32(__m256i a, __m256i b) {
943 // CHECK-LABEL: test_mm256_max_epu32
944 // CHECK: call <8 x i32> @llvm.umax.v8i32(<8 x i32> %{{.*}}, <8 x i32> %{{.*}})
945 return _mm256_max_epu32(a, b);
946 }
947
948 TEST_CONSTEXPR(match_v8su(_mm256_max_epu32((__m256i)(__v8su){1, 2, 3, 4, 5, 6, 7, 8}, (__m256i)(__v8su){0, 1, 2, 3, 4, 5, 6, 7}), 1, 2, 3, 4, 5, 6, 7, 8));
949
950 __m256i test_mm256_min_epi8(__m256i a, __m256i b) {
951 // CHECK-LABEL: test_mm256_min_epi8
952 // CHECK: call <32 x i8> @llvm.smin.v32i8(<32 x i8> %{{.*}}, <32 x i8> %{{.*}})
953 return _mm256_min_epi8(a, b);
954 }
955
956 TEST_CONSTEXPR(match_v32qi(_mm256_min_epi8((__m256i)(__v32qs){+1, -2, +3, -4, +5, -6, +7, -8, +9, -10, +11, -12, +13, -14, +15, -16, +17, -18, +19, -20, +21, -22, +23, -24, +25, -26, +27, -28, +29, -30, +31, -32}, (__m256i)(__v32qs){-1, +2, -3, +4, -5, +6, -7, +8, -9, +10, -11, +12, -13, +14, -15, +16, -17, +18, -19, +20, -21, +22, -23, +24, -25, +26, -27, +28, -29, +30, -31, +32}), -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20, -21, -22, -23, -24, -25, -26, -27, -28, -29, -30, -31, -32));
957
958 __m256i test_mm256_min_epi16(__m256i a, __m256i b) {
959 // CHECK-LABEL: test_mm256_min_epi16
960 // CHECK: call <16 x i16> @llvm.smin.v16i16(<16 x i16> %{{.*}}, <16 x i16> %{{.*}})
961 return _mm256_min_epi16(a, b);
962 }
963
964 TEST_CONSTEXPR(match_v16hi(_mm256_min_epi16((__m256i)(__v16hi){+1, -2, +3, -4, +5, -6, +7, -8, +9, -10, +11, -12, +13, -14, +15, -16}, (__m256i)(__v16hi){-1, +2, -3, +4, -5, +6, -7, +8, -9, +10, -11, +12, -13, +14, -15, +16}), -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16));
965
966 __m256i test_mm256_min_epi32(__m256i a, __m256i b) {
967 // CHECK-LABEL: test_mm256_min_epi32
968 // CHECK: call <8 x i32> @llvm.smin.v8i32(<8 x i32> %{{.*}}, <8 x i32> %{{.*}})
969 return _mm256_min_epi32(a, b);
970 }
971
972 TEST_CONSTEXPR(match_v8si(_mm256_min_epi32((__m256i)(__v8si){+1, -2, +3, -4, +5, -6, +7, -8}, (__m256i)(__v8si){-1, +2, -3, +4, -5, +6, -7, +8}), -1, -2, -3, -4, -5, -6, -7, -8));
973
974 __m256i test_mm256_min_epu8(__m256i a, __m256i b) {
975 // CHECK-LABEL: test_mm256_min_epu8
976 // CHECK: call <32 x i8> @llvm.umin.v32i8(<32 x i8> %{{.*}}, <32 x i8> %{{.*}})
977 return _mm256_min_epu8(a, b);
978 }
979
980 TEST_CONSTEXPR(match_v32qu(_mm256_min_epu8((__m256i)(__v32qu){1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32}, (__m256i)(__v32qu){0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31}), 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31));
981
982 __m256i test_mm256_min_epu16(__m256i a, __m256i b) {
983 // CHECK-LABEL: test_mm256_min_epu16
984 // CHECK: call <16 x i16> @llvm.umin.v16i16(<16 x i16> %{{.*}}, <16 x i16> %{{.*}})
985 return _mm256_min_epu16(a, b);
986 }
987
988 TEST_CONSTEXPR(match_v16hu(_mm256_min_epu16((__m256i)(__v16hu){1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}, (__m256i)(__v16hu){0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}), 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15));
989
990 __m256i test_mm256_min_epu32(__m256i a, __m256i b) {
991 // CHECK-LABEL: test_mm256_min_epu32
992 // CHECK: call <8 x i32> @llvm.umin.v8i32(<8 x i32> %{{.*}}, <8 x i32> %{{.*}})
993 return _mm256_min_epu32(a, b);
994 }
995
996 TEST_CONSTEXPR(match_v8su(_mm256_min_epu32((__m256i)(__v8su){1, 2, 3, 4, 5, 6, 7, 8}, (__m256i)(__v8su){0, 1, 2, 3, 4, 5, 6, 7}), 0, 1, 2, 3, 4, 5, 6, 7));
997
998 int test_mm256_movemask_epi8(__m256i a) {
999 // CHECK-LABEL: test_mm256_movemask_epi8
1000 // CHECK: call {{.*}}i32 @llvm.x86.avx2.pmovmskb(<32 x i8> %{{.*}})
1001 return _mm256_movemask_epi8(a);
1002 }
1003 TEST_CONSTEXPR(_mm256_movemask_epi8((__m256i)(__v32qu){0x7F,0x80,0x01,0xFF,0x00,0xAA,0x55,0xC3,0x12,0x8E,0x00,0xFE,0x7E,0x81,0xFF,0x01,0xB6,0x00,0x39,0x40,0xD0,0x05,0x80,0x2A,0x7B,0x00,0x90,0xFF,0x01,0x34,0xC0,0x6D}) == 0x4C516AAA);
1004 TEST_CONSTEXPR(_mm256_movemask_epi8((__m256i)(__v8si){(int)0x80FF00AA,(int)0x7F0183E1,(int)0xDEADBEEF,(int)0xC0000001,(int)0x00000000,(int)0xFFFFFFFF,(int)0x12345678,(int)0x90ABCDEF}) == 0xF0F08F3D);
1005 TEST_CONSTEXPR(_mm256_movemask_epi8((__m256i)(__v4du){0xFF00000000000080ULL,0x7F010203040506C3ULL,0x8000000000000000ULL,0x0123456789ABCDEFULL}) == 0x0F800181);
1006
1007 __m256i test_mm256_mpsadbw_epu8(__m256i x, __m256i y) {
1008 // CHECK-LABEL: test_mm256_mpsadbw_epu8
1009 // CHECK: call <16 x i16> @llvm.x86.avx2.mpsadbw(<32 x i8> %{{.*}}, <32 x i8> %{{.*}}, i8 3)
1010 return _mm256_mpsadbw_epu8(x, y, 3);
1011 }
1012
1013 __m256i test_mm256_mul_epi32(__m256i a, __m256i b) {
1014 // CHECK-LABEL: test_mm256_mul_epi32
1015 // CHECK: shl <4 x i64> %{{.*}}, splat (i64 32)
1016 // CHECK: ashr <4 x i64> %{{.*}}, splat (i64 32)
1017 // CHECK: shl <4 x i64> %{{.*}}, splat (i64 32)
1018 // CHECK: ashr <4 x i64> %{{.*}}, splat (i64 32)
1019 // CHECK: mul <4 x i64> %{{.*}}, %{{.*}}
1020 return _mm256_mul_epi32(a, b);
1021 }
1022 TEST_CONSTEXPR(match_m256i(_mm256_mul_epi32((__m256i)(__v8si){+1, -2, +3, -4, +5, -6, +7, -8}, (__m256i)(__v8si){-16, -14, +12, +10, -8, +6, -4, +2}), -16, 36, -40, -28));
1023
1024 __m256i test_mm256_mul_epu32(__m256i a, __m256i b) {
1025 // CHECK-LABEL: test_mm256_mul_epu32
1026 // CHECK: and <4 x i64> %{{.*}}, splat (i64 4294967295)
1027 // CHECK: and <4 x i64> %{{.*}}, splat (i64 4294967295)
1028 // CHECK: mul <4 x i64> %{{.*}}, %{{.*}}
1029 return _mm256_mul_epu32(a, b);
1030 }
1031 TEST_CONSTEXPR(match_m256i(_mm256_mul_epu32((__m256i)(__v8si){+1, -2, +3, -4, +5, -6, +7, -8}, (__m256i)(__v8si){-16, -14, +12, +10, -8, +6, -4, +2}), 4294967280, 36, 21474836440, 30064771044));
1032
1033 __m256i test_mm256_mulhi_epu16(__m256i a, __m256i b) {
1034 // CHECK-LABEL: test_mm256_mulhi_epu16
1035 // CHECK: call <16 x i16> @llvm.x86.avx2.pmulhu.w(<16 x i16> %{{.*}}, <16 x i16> %{{.*}})
1036 return _mm256_mulhi_epu16(a, b);
1037 }
1038 TEST_CONSTEXPR(match_v16hi(_mm256_mulhi_epu16((__m256i)(__v16hi){+1, -2, +3, -4, +5, -6, +7, -8, +9, -10, +11, -12, +13, -14, +15, -16}, (__m256i)(__v16hi){-32, -30, +28, +26, -24, -22, +20, +18, -16, -14, +12, +10, -8, +6, -4, +2}), 0, -32, 0, 25, 4, -28, 0, 17, 8, -24, 0, 9, 12, 5, 14, 1));
1039
1040 __m256i test_mm256_mulhi_epi16(__m256i a, __m256i b) {
1041 // CHECK-LABEL: test_mm256_mulhi_epi16
1042 // CHECK: call <16 x i16> @llvm.x86.avx2.pmulh.w(<16 x i16> %{{.*}}, <16 x i16> %{{.*}})
1043 return _mm256_mulhi_epi16(a, b);
1044 }
1045 TEST_CONSTEXPR(match_v16hi(_mm256_mulhi_epi16((__m256i)(__v16hi){+1, -2, +3, -4, +5, -6, +7, -8, +9, -10, +11, -12, +13, -14, +15, -16}, (__m256i)(__v16hi){-32, -30, +28, +26, -24, -22, +20, +18, -16, -14, +12, +10, -8, +6, -4, +2}), -1, 0, 0, -1, -1, 0, 0, -1, -1, 0, 0, -1, -1, -1, -1, -1));
1046
1047 __m256i test_mm256_mulhrs_epi16(__m256i a, __m256i b) {
1048 // CHECK-LABEL: test_mm256_mulhrs_epi16
1049 // CHECK: call <16 x i16> @llvm.x86.avx2.pmul.hr.sw(<16 x i16> %{{.*}}, <16 x i16> %{{.*}})
1050 return _mm256_mulhrs_epi16(a, b);
1051 }
1052 TEST_CONSTEXPR(match_v16hi(_mm256_mulhrs_epi16((__m256i)(__v16hi){+100, +200, -300, -400, +500, +600, -700, +800, -900, -1000, +1100, +1200, -1300, -1400, +1500, +1600}, (__m256i)(__v16hi){+1600, -1500, +1400, -1300, +1200, -1100, +1000, -900, +800, -700, +600, -500, +400, -300, +200, -100}), +5, -9, -13, +16, +18, -20, -21, -22, -22, +21, +20, -18, -16, +13, +9, -5));
1053
1054 __m256i test_mm256_mullo_epi16(__m256i a, __m256i b) {
1055 // CHECK-LABEL: test_mm256_mullo_epi16
1056 // CHECK: mul <16 x i16>
1057 return _mm256_mullo_epi16(a, b);
1058 }
1059 TEST_CONSTEXPR(match_v16hi(_mm256_mullo_epi16((__m256i)(__v16hi){+1, -2, +3, -4, +5, -6, +7, -8, +9, -10, +11, -12, +13, -14, +15, -16}, (__m256i)(__v16hi){-32, -30, +28, +26, -24, -22, +20, +18, -16, -14, +12, +10, -8, +6, -4, +2}), -32, 60, 84, -104, -120, 132, 140, -144, -144, 140, 132, -120, -104, -84, -60, -32));
1060
1061 __m256i test_mm256_mullo_epi32(__m256i a, __m256i b) {
1062 // CHECK-LABEL: test_mm256_mullo_epi32
1063 // CHECK: mul <8 x i32>
1064 return _mm256_mullo_epi32(a, b);
1065 }
1066 TEST_CONSTEXPR(match_v8si(_mm256_mullo_epi32((__m256i)(__v8si){+1, -2, +3, -4, +5, -6, +7, -8}, (__m256i)(__v8si){-16, -14, +12, +10, -8, +6, -4, +2}), -16, 28, 36, -40, -40, -36, -28, -16));
1067
1068 __m256i test_mm256_or_si256(__m256i a, __m256i b) {
1069 // CHECK-LABEL: test_mm256_or_si256
1070 // CHECK: or <4 x i64>
1071 return _mm256_or_si256(a, b);
1072 }
1073 TEST_CONSTEXPR(match_v4di(_mm256_or_si256((__m256i)(__v4di){0, -1, 0, -1}, (__m256i)(__v4di){0, 0, -1, -1}), 0, -1, -1, -1));
1074
1075 __m256i test_mm256_packs_epi16(__m256i a, __m256i b) {
1076 // CHECK-LABEL: test_mm256_packs_epi16
1077 // CHECK: call <32 x i8> @llvm.x86.avx2.packsswb(<16 x i16> %{{.*}}, <16 x i16> %{{.*}})
1078 return _mm256_packs_epi16(a, b);
1079 }
1080 TEST_CONSTEXPR(match_v32qi(_mm256_packs_epi16((__m256i)(__v16hi){130, -200, 127, -128, 300, -1000, 42, -42, 500, -500, 1, -1, 128, -129, 256, -256}, (__m256i)(__v16hi){0, 1, -1, 255, -129, 128, 20000, -32768, 32767, -32767, 127, -128, 30000, -30000, 90, -90}), 127, -128, 127, -128, 127, -128, 42, -42, 0, 1, -1, 127, -128, 127, 127, -128, 127, -128, 1, -1, 127, -128, 127, -128, 127, -128, 127, -128, 127, -128, 90, -90));
1081
1082 __m256i test_mm256_packs_epi32(__m256i a, __m256i b) {
1083 // CHECK-LABEL: test_mm256_packs_epi32
1084 // CHECK: call <16 x i16> @llvm.x86.avx2.packssdw(<8 x i32> %{{.*}}, <8 x i32> %{{.*}})
1085 return _mm256_packs_epi32(a, b);
1086 }
1087 TEST_CONSTEXPR(match_v16hi(_mm256_packs_epi32((__m256i)(__v8si){40000, -50000, 32767, -32768, 70000, -70000, 42, -42}, (__m256i)(__v8si){0, 1, -1, 65536, -1000000, 1000000, 32768, -32769}), 32767, -32768, 32767, -32768, 0, 1, -1, 32767, 32767, -32768, 42, -42, -32768, 32767, 32767, -32768));
1088
1089 __m256i test_mm256_packs_epu16(__m256i a, __m256i b) {
1090 // CHECK-LABEL: test_mm256_packs_epu16
1091 // CHECK: call <32 x i8> @llvm.x86.avx2.packuswb(<16 x i16> %{{.*}}, <16 x i16> %{{.*}})
1092 return _mm256_packus_epi16(a, b);
1093 }
1094 TEST_CONSTEXPR(match_v32qi(_mm256_packus_epi16((__m256i)(__v16hi){-1, 0, 1, 127, 128, 255, 256, -200, 300, 42, -42, 500, 20000, -32768, 129, -129}, (__m256i)(__v16hi){0, 1, -1, 255, -129, 128, 20000, -32768, 32767, -32767, 127, -128, 30000, -30000, 90, -90}), 0, 0, 1, 127, -128, -1, -1, 0, 0, 1, 0, -1, 0, -128, -1, 0, -1, 42, 0, -1, -1, 0, -127, 0, -1, 0, 127, 0, -1, 0, 90, 0));
1095
1096 __m256i test_mm256_packs_epu32(__m256i a, __m256i b) {
1097 // CHECK-LABEL: test_mm256_packs_epu32
1098 // CHECK: call <16 x i16> @llvm.x86.avx2.packusdw(<8 x i32> %{{.*}}, <8 x i32> %{{.*}})
1099 return _mm256_packus_epi32(a, b);
1100 }
1101 TEST_CONSTEXPR(match_v16hi(_mm256_packus_epi32((__m256i)(__v8si){40000, -50000, 32767, -32768, 70000, -70000, 42, -42}, (__m256i)(__v8si){0, 1, -1, 65536, -1000000, 1000000, 32768, -32769}), -25536, 0, 32767, 0, 0, 1, 0, -1, -1, 0, 42, 0, 0, -1, -32768, 0));
1102
1103 __m256i test_mm256_permute2x128_si256(__m256i a, __m256i b) {
1104 // CHECK-LABEL: test_mm256_permute2x128_si256
1105 // CHECK: shufflevector <4 x i64> zeroinitializer, <4 x i64> %{{.*}}, <4 x i32> <i32 0, i32 1, i32 6, i32 7>
1106 return _mm256_permute2x128_si256(a, b, 0x38);
1107 }
1108
1109 TEST_CONSTEXPR(match_m256i(_mm256_permute2x128_si256(((__m256i){1LL, 2LL, 3LL, 4LL}), ((__m256i){5LL, 6LL, 7LL, 8LL}), 0xA7), 7LL, 8LL, 0LL, 0LL));
1110 TEST_CONSTEXPR(match_m256i(_mm256_permute2x128_si256(((__m256i){1LL, 2LL, 3LL, 4LL}), ((__m256i){5LL, 6LL, 7LL, 8LL}), 0x5F), 0LL, 0LL, 3LL, 4LL));
1111 TEST_CONSTEXPR(match_m256i(_mm256_permute2x128_si256(((__m256i){1LL, 2LL, 3LL, 4LL}), ((__m256i){5LL, 6LL, 7LL, 8LL}), 0x37), 7LL, 8LL, 7LL, 8LL));
1112 TEST_CONSTEXPR(match_m256i(_mm256_permute2x128_si256(((__m256i){1LL, 2LL, 3LL, 4LL}), ((__m256i){5LL, 6LL, 7LL, 8LL}), 0x12), 5LL, 6LL, 3LL, 4LL));
1113
1114 __m256i test_mm256_permute4x64_epi64(__m256i a) {
1115 // CHECK-LABEL: test_mm256_permute4x64_epi64
1116 // CHECK: shufflevector <4 x i64> %{{.*}}, <4 x i64> poison, <4 x i32> <i32 3, i32 0, i32 2, i32 0>
1117 return _mm256_permute4x64_epi64(a, 35);
1118 }
1119 // Control value 0x00: [0,0,0,0] -> broadcast element 0
1120 TEST_CONSTEXPR(match_v4di(_mm256_permute4x64_epi64(((__m256i)(__v4di){40LL, 30LL, 20LL, 10LL}), 0x00), 40LL, 40LL, 40LL, 40LL));
1121 // Control value 0x1B: [0,1,2,3] -> reverse order [3,2,1,0] = [D,C,B,A]
1122 TEST_CONSTEXPR(match_v4di(_mm256_permute4x64_epi64(((__m256i)(__v4di){40LL, 30LL, 20LL, 10LL}), 0x1B), 10LL, 20LL, 30LL, 40LL));
1123 // Control value 0x39: [1,2,3,0] -> rotate left [B,C,D,A]
1124 TEST_CONSTEXPR(match_v4di(_mm256_permute4x64_epi64(((__m256i)(__v4di){40LL, 30LL, 20LL, 10LL}), 0x39), 30LL, 20LL, 10LL, 40LL));
1125 // Control value 0x12: [2,0,1,0] -> [C,A,B,A]
1126 TEST_CONSTEXPR(match_v4di(_mm256_permute4x64_epi64(((__m256i)(__v4di){40LL, 30LL, 20LL, 10LL}), 0x12), 20LL, 40LL, 30LL, 40LL));
1127 // Control value 0xE4: [3,2,1,0] -> identity [A,B,C,D]
1128 TEST_CONSTEXPR(match_v4di(_mm256_permute4x64_epi64(((__m256i)(__v4di){40LL, 30LL, 20LL, 10LL}), 0xE4), 40LL, 30LL, 20LL, 10LL));
1129 // Test with negative values
1130 TEST_CONSTEXPR(match_v4di(_mm256_permute4x64_epi64(((__m256i)(__v4di){-40LL, -30LL, -20LL, -10LL}), 0x1B), -10LL, -20LL, -30LL, -40LL));
1131
1132 __m256d test_mm256_permute4x64_pd(__m256d a) {
1133 // CHECK-LABEL: test_mm256_permute4x64_pd
1134 // CHECK: shufflevector <4 x double> %{{.*}}, <4 x double> poison, <4 x i32> <i32 1, i32 2, i32 1, i32 0>
1135 return _mm256_permute4x64_pd(a, 25);
1136 }
1137 // Control value 0x00: [0,0,0,0] -> broadcast element 0
1138 TEST_CONSTEXPR(match_m256d(_mm256_permute4x64_pd(((__m256d){4.0, 3.0, 2.0, 1.0}), 0x00), 4.0, 4.0, 4.0, 4.0));
1139 // Control value 0x1B: [0,1,2,3] -> reverse order [3,2,1,0] = [D,C,B,A]
1140 TEST_CONSTEXPR(match_m256d(_mm256_permute4x64_pd(((__m256d){4.0, 3.0, 2.0, 1.0}), 0x1B), 1.0, 2.0, 3.0, 4.0));
1141 // Control value 0x39: [1,2,3,0] -> rotate left [B,C,D,A]
1142 TEST_CONSTEXPR(match_m256d(_mm256_permute4x64_pd(((__m256d){4.0, 3.0, 2.0, 1.0}), 0x39), 3.0, 2.0, 1.0, 4.0));
1143 // Control value 0x12: [2,0,1,0] -> [C,A,B,A]
1144 TEST_CONSTEXPR(match_m256d(_mm256_permute4x64_pd(((__m256d){4.0, 3.0, 2.0, 1.0}), 0x12), 2.0, 4.0, 3.0, 4.0));
1145 // Control value 0xE4: [3,2,1,0] -> identity [A,B,C,D]
1146 TEST_CONSTEXPR(match_m256d(_mm256_permute4x64_pd(((__m256d){4.0, 3.0, 2.0, 1.0}), 0xE4), 4.0, 3.0, 2.0, 1.0));
1147
1148 __m256i test_mm256_permutevar8x32_epi32(__m256i a, __m256i b) {
1149 // CHECK-LABEL: test_mm256_permutevar8x32_epi32
1150 // CHECK: call <8 x i32> @llvm.x86.avx2.permd(<8 x i32> %{{.*}}, <8 x i32> %{{.*}})
1151 return _mm256_permutevar8x32_epi32(a, b);
1152 }
1153 TEST_CONSTEXPR(match_v8si(_mm256_permutevar8x32_epi32((__m256i)(__v8si){7, 6, 5, 4, 3, 2, 1, 0}, (__m256i)(__v8si){0, 1, 2, 3, 4, 5, 6, 7}), 7, 6, 5, 4, 3, 2, 1, 0));
1154 TEST_CONSTEXPR(match_v8si(_mm256_permutevar8x32_epi32((__m256i)(__v8si){0, 0, 0, 0, 0, 0, 0, 0}, (__m256i)(__v8si){1, 2, 3, 4, 5, 6, 7, 8}), 0, 0, 0, 0, 0, 0, 0, 0));
1155
1156 __m256 test_mm256_permutevar8x32_ps(__m256 a, __m256i b) {
1157 // CHECK-LABEL: test_mm256_permutevar8x32_ps
1158 // CHECK: call {{.*}}<8 x float> @llvm.x86.avx2.permps(<8 x float> %{{.*}}, <8 x i32> %{{.*}})
1159 return _mm256_permutevar8x32_ps(a, b);
1160 }
1161 TEST_CONSTEXPR(match_m256(_mm256_permutevar8x32_ps((__m256){7.0f, 6.0f, 5.0f, 4.0f, 3.0f, 2.0f, 1.0f, 0.0f}, (__m256i)(__v8si){0, 1, 2, 3, 4, 5, 6, 7}), 7.0f, 6.0f, 5.0f, 4.0f, 3.0f, 2.0f, 1.0f, 0.0f));
1162 TEST_CONSTEXPR(match_m256(_mm256_permutevar8x32_ps((__m256){0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, (__m256i)(__v8si){1, 2, 3, 4, 5, 6, 7, 8}), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f));
1163
1164 __m256i test_mm256_sad_epu8(__m256i x, __m256i y) {
1165 // CHECK-LABEL: test_mm256_sad_epu8
1166 // CHECK: call {{.*}}<4 x i64> @llvm.x86.avx2.psad.bw(<32 x i8> %{{.*}}, <32 x i8> %{{.*}})
1167 return _mm256_sad_epu8(x, y);
1168 }
1169
1170 __m256i test_mm256_shuffle_epi8(__m256i a, __m256i b) {
1171 // CHECK-LABEL: test_mm256_shuffle_epi8
1172 // CHECK: call <32 x i8> @llvm.x86.avx2.pshuf.b(<32 x i8> %{{.*}}, <32 x i8> %{{.*}})
1173 return _mm256_shuffle_epi8(a, b);
1174 }
1175
1176 TEST_CONSTEXPR(match_v32qi(_mm256_shuffle_epi8((__m256i)(__v32qi){0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31}, (__m256i)(__v32qs){0,33,2,35,4,37,6,-39,8,41,10,43,12,45,14,-47,16,49,18,51,20,53,22,-55,24,57,26,59,28,61,30,-63}), 0,1,2,3,4,5,6,0,8,9,10,11,12,13,14,0,16,17,18,19,20,21,22,0,24,25,26,27,28,29,30,0));
1177
1178 __m256i test_mm256_shuffle_epi32(__m256i a) {
1179 // CHECK-LABEL: test_mm256_shuffle_epi32
1180 // CHECK: shufflevector <8 x i32> %{{.*}}, <8 x i32> poison, <8 x i32> <i32 3, i32 3, i32 0, i32 0, i32 7, i32 7, i32 4, i32 4>
1181 return _mm256_shuffle_epi32(a, 15);
1182 }
1183 TEST_CONSTEXPR(match_v8si(_mm256_shuffle_epi32((((__m256i)(__v8si){0,1,2,3,4,5,6,7})), 15), 3,3,0,0, 7,7,4,4));
1184 __m256i test_mm256_shufflehi_epi16(__m256i a) {
1185 // CHECK-LABEL: test_mm256_shufflehi_epi16
1186 // CHECK: shufflevector <16 x i16> %{{.*}}, <16 x i16> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 7, i32 6, i32 6, i32 5, i32 8, i32 9, i32 10, i32 11, i32 15, i32 14, i32 14, i32 13>
1187 return _mm256_shufflehi_epi16(a, 107);
1188 }
1189 TEST_CONSTEXPR(match_v16hi(_mm256_shufflehi_epi16((((__m256i)(__v16hi){0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15})), 107), 0,1,2,3, 7,6,6,5, 8,9,10,11, 15,14,14,13));
1190 __m256i test_mm256_shufflelo_epi16(__m256i a) {
1191 // CHECK-LABEL: test_mm256_shufflelo_epi16
1192 // CHECK: shufflevector <16 x i16> %{{.*}}, <16 x i16> poison, <16 x i32> <i32 3, i32 0, i32 1, i32 1, i32 4, i32 5, i32 6, i32 7, i32 11, i32 8, i32 9, i32 9, i32 12, i32 13, i32 14, i32 15>
1193 return _mm256_shufflelo_epi16(a, 83);
1194 }
1195 TEST_CONSTEXPR(match_v16hi(_mm256_shufflelo_epi16(((__m256i)(__v16hi){ 0,1,2,3, 4,5,6,7, 8,9,10,11, 12,13,14,15}), 83), 3,0,1,1, 4,5,6,7, 11,8,9,9, 12,13,14,15) );
1196
1197 __m256i test_mm256_sign_epi8(__m256i a, __m256i b) {
1198 // CHECK-LABEL: test_mm256_sign_epi8
1199 // CHECK: call <32 x i8> @llvm.x86.avx2.psign.b(<32 x i8> %{{.*}}, <32 x i8> %{{.*}})
1200 return _mm256_sign_epi8(a, b);
1201 }
1202 TEST_CONSTEXPR(match_v32qi(_mm256_sign_epi8(
1203 (__m256i)(__v32qs){0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
1204 (__m256i)(__v32qs){0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1}),
1205 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1));
1206
1207 __m256i test_mm256_sign_epi16(__m256i a, __m256i b) {
1208 // CHECK-LABEL: test_mm256_sign_epi16
1209 // CHECK: call <16 x i16> @llvm.x86.avx2.psign.w(<16 x i16> %{{.*}}, <16 x i16> %{{.*}})
1210 return _mm256_sign_epi16(a, b);
1211 }
1212 TEST_CONSTEXPR(match_v16hi(_mm256_sign_epi16((__m256i)(__v16hi){0x77,0x77,0xbe,0xbe, -0x9,-0x9,-0x8,-0x8, 0,0,0,0, 0,0,0,0}, (__m256i)(__v16hi){-1,-256,1,256, -512,-1028,512,1028, -2048,-4096,0,0, 0,0,0,0}), -0x77,-0x77,0xbe,0xbe, 0x9,0x9,-0x8,-0x8, 0,0,0,0, 0,0,0,0));
1213
1214 __m256i test_mm256_sign_epi32(__m256i a, __m256i b) {
1215 // CHECK-LABEL: test_mm256_sign_epi32
1216 // CHECK: call <8 x i32> @llvm.x86.avx2.psign.d(<8 x i32> %{{.*}}, <8 x i32> %{{.*}})
1217 return _mm256_sign_epi32(a, b);
1218 }
1219 TEST_CONSTEXPR(match_v8si(_mm256_sign_epi32((__m256i)(__v8si){0xbeef,0xfeed,0xbead,0xdeed, -1,2,-3,4}, (__m256i)(__v8si){0,0,0,0,-1,-1,-1,-1}), 0,0,0,0, 1,-2,3,-4));
1220
1221 __m256i test_mm256_sll_epi16(__m256i a, __m128i b) {
1222 // CHECK-LABEL: test_mm256_sll_epi16
1223 // CHECK: call <16 x i16> @llvm.x86.avx2.psll.w(<16 x i16> %{{.*}}, <8 x i16> %{{.*}})
1224 return _mm256_sll_epi16(a, b);
1225 }
1226 TEST_CONSTEXPR(match_v16hi(_mm256_sll_epi16((__m256i)(__v16hi){0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, (__m128i)(__v8hi){1, 0, 0, 0, 0, 0, 0, 0}), 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30));
1227 TEST_CONSTEXPR(match_v16hi(_mm256_sll_epi16((__m256i)(__v16hi){0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, (__m128i)(__v8hi){16, 0, 0, 0, 0, 0, 0, 0}), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
1228 TEST_CONSTEXPR(match_v16hi(_mm256_sll_epi16((__m256i)(__v16hi){0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, (__m128i)(__v8hi){0, 1, 0, 0, 0, 0, 0, 0}), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
1229 TEST_CONSTEXPR(match_v16hi(_mm256_sll_epi16((__m256i)(__v16hi){0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, (__m128i)(__v8hi){0, 0, 1, 0, 0, 0, 0, 0}), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
1230 TEST_CONSTEXPR(match_v16hi(_mm256_sll_epi16((__m256i)(__v16hi){0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, (__m128i)(__v8hi){0, 0, 0, 1, 0, 0, 0, 0}), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
1231 TEST_CONSTEXPR(match_v16hi(_mm256_sll_epi16((__m256i)(__v16hi){0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, (__m128i)(__v8hi){1, 0, 0, 0, 1, 1, 1, 1}), 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30));
1232
1233 __m256i test_mm256_sll_epi32(__m256i a, __m128i b) {
1234 // CHECK-LABEL: test_mm256_sll_epi32
1235 // CHECK: call <8 x i32> @llvm.x86.avx2.psll.d(<8 x i32> %{{.*}}, <4 x i32> %{{.*}})
1236 return _mm256_sll_epi32(a, b);
1237 }
1238 TEST_CONSTEXPR(match_v8si(_mm256_sll_epi32((__m256i)(__v8si){0, 1, 2, 3, 4, 5, 6, 7}, (__m128i)(__v4si){1, 0, 0, 0}), 0, 2, 4, 6, 8, 10, 12, 14));
1239 TEST_CONSTEXPR(match_v8si(_mm256_sll_epi32((__m256i)(__v8si){0, 1, 2, 3, 4, 5, 6, 7}, (__m128i)(__v4si){32, 0, 0, 0}), 0, 0, 0, 0, 0, 0, 0, 0));
1240 TEST_CONSTEXPR(match_v8si(_mm256_sll_epi32((__m256i)(__v8si){0, 1, 2, 3, 4, 5, 6, 7}, (__m128i)(__v4si){0, 1, 0, 0}), 0, 0, 0, 0, 0, 0, 0, 0));
1241 TEST_CONSTEXPR(match_v8si(_mm256_sll_epi32((__m256i)(__v8si){0, 1, 2, 3, 4, 5, 6, 7}, (__m128i)(__v4si){1, 0, 1, 1}), 0, 2, 4, 6, 8, 10, 12, 14));
1242
1243 __m256i test_mm256_sll_epi64(__m256i a, __m128i b) {
1244 // CHECK-LABEL: test_mm256_sll_epi64
1245 // CHECK: call {{.*}}<4 x i64> @llvm.x86.avx2.psll.q(<4 x i64> %{{.*}}, <2 x i64> %{{.*}})
1246 return _mm256_sll_epi64(a, b);
1247 }
1248 TEST_CONSTEXPR(match_v4di(_mm256_sll_epi64((__m256i)(__v4di){0, 1, 2, 3}, (__m128i)(__v2di){1, 0}), 0, 2, 4, 6));
1249 TEST_CONSTEXPR(match_v4di(_mm256_sll_epi64((__m256i)(__v4di){0, 1, 2, 3}, (__m128i)(__v2di){64, 0}), 0, 0, 0, 0));
1250 TEST_CONSTEXPR(match_v4di(_mm256_sll_epi64((__m256i)(__v4di){0, 1, 2, 3}, (__m128i)(__v2di){1, 1}), 0, 2, 4, 6));
1251
1252 __m256i test_mm256_slli_epi16(__m256i a) {
1253 // CHECK-LABEL: test_mm256_slli_epi16
1254 // CHECK: call <16 x i16> @llvm.x86.avx2.pslli.w(<16 x i16> %{{.*}}, i32 %{{.*}})
1255 return _mm256_slli_epi16(a, 3);
1256 }
1257 TEST_CONSTEXPR(match_v16hi(_mm256_slli_epi16((__m256i)(__v16hi){0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, 0), 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15));
1258 TEST_CONSTEXPR(match_v16hi(_mm256_slli_epi16((__m256i)(__v16hi){0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, 1), 0, 0x2, 0x4, 0x6, 0x8, 0xa, 0xc, 0xe, 0x10, 0x12, 0x14, 0x16, 0x18, 0x1a, 0x1c, 0x1e));
1259 TEST_CONSTEXPR(match_v16hi(_mm256_slli_epi16((__m256i)(__v16hi){0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, 15), 0, 0x8000, 0x0, 0x8000, 0x0, 0x8000, 0x0, 0x8000, 0x0, 0x8000, 0x0, 0x8000, 0x0, 0x8000, 0x0, 0x8000));
1260 TEST_CONSTEXPR(match_v16hi(_mm256_slli_epi16((__m256i)(__v16hi){0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, 16), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
1261 TEST_CONSTEXPR(match_v16hi(_mm256_slli_epi16((__m256i)(__v16hi){0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, 17), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
1262
1263 __m256i test_mm256_slli_epi16_2(__m256i a, int b) {
1264 // CHECK-LABEL: test_mm256_slli_epi16_2
1265 // CHECK: call <16 x i16> @llvm.x86.avx2.pslli.w(<16 x i16> %{{.*}}, i32 %{{.*}})
1266 return _mm256_slli_epi16(a, b);
1267 }
1268
1269 __m256i test_mm256_slli_epi32(__m256i a) {
1270 // CHECK-LABEL: test_mm256_slli_epi32
1271 // CHECK: call <8 x i32> @llvm.x86.avx2.pslli.d(<8 x i32> %{{.*}}, i32 %{{.*}})
1272 return _mm256_slli_epi32(a, 3);
1273 }
1274 TEST_CONSTEXPR(match_v8si(_mm256_slli_epi32((__m256i)(__v8si){0, 1, 2, 3, 4, 5, 6, 7}, 0), 0, 1, 2, 3, 4, 5, 6, 7));
1275 TEST_CONSTEXPR(match_v8si(_mm256_slli_epi32((__m256i)(__v8si){0, 1, 2, 3, 4, 5, 6, 7}, 1), 0, 0x2, 0x4, 0x6, 0x8, 0xa, 0xc, 0xe));
1276 TEST_CONSTEXPR(match_v8su(_mm256_slli_epi32((__m256i)(__v8su){0, 1, 2, 3, 4, 5, 6, 7}, 31), 0, 0x80000000, 0x0, 0x80000000, 0x0, 0x80000000, 0x0, 0x80000000));
1277 TEST_CONSTEXPR(match_v8si(_mm256_slli_epi32((__m256i)(__v8si){0, 1, 2, 3, 4, 5, 6, 7}, 32), 0, 0, 0, 0, 0, 0, 0, 0));
1278 TEST_CONSTEXPR(match_v8si(_mm256_slli_epi32((__m256i)(__v8si){0, 1, 2, 3, 4, 5, 6, 7}, 33), 0, 0, 0, 0, 0, 0, 0, 0));
1279
1280 __m256i test_mm256_slli_epi32_2(__m256i a, int b) {
1281 // CHECK-LABEL: test_mm256_slli_epi32_2
1282 // CHECK: call <8 x i32> @llvm.x86.avx2.pslli.d(<8 x i32> %{{.*}}, i32 %{{.*}})
1283 return _mm256_slli_epi32(a, b);
1284 }
1285
1286 __m256i test_mm256_slli_epi64(__m256i a) {
1287 // CHECK-LABEL: test_mm256_slli_epi64
1288 // CHECK: call {{.*}}<4 x i64> @llvm.x86.avx2.pslli.q(<4 x i64> %{{.*}}, i32 %{{.*}})
1289 return _mm256_slli_epi64(a, 3);
1290 }
1291 TEST_CONSTEXPR(match_v4di(_mm256_slli_epi64((__m256i)(__v4di){0, 1, 2, 3}, 0), 0, 1, 2, 3));
1292 TEST_CONSTEXPR(match_v4di(_mm256_slli_epi64((__m256i)(__v4di){0, 1, 2, 3}, 1), 0, 0x2, 0x4, 0x6));
1293 TEST_CONSTEXPR(match_v4di(_mm256_slli_epi64((__m256i)(__v4di){0, 1, 2, 3}, 33), 0, 0x200000000LL, 0x400000000LL, 0x600000000LL));
1294 TEST_CONSTEXPR(match_v4di(_mm256_slli_epi64((__m256i)(__v4di){0, 1, 2, 3}, 64), 0, 0, 0, 0));
1295 TEST_CONSTEXPR(match_v4di(_mm256_slli_epi64((__m256i)(__v4di){0, 1, 2, 3}, 65), 0, 0, 0, 0));
1296
1297 __m256i test_mm256_slli_epi64_2(__m256i a, int b) {
1298 // CHECK-LABEL: test_mm256_slli_epi64_2
1299 // CHECK: call {{.*}}<4 x i64> @llvm.x86.avx2.pslli.q(<4 x i64> %{{.*}}, i32 %{{.*}})
1300 return _mm256_slli_epi64(a, b);
1301 }
1302
1303 __m256i test_mm256_slli_si256(__m256i a) {
1304 // CHECK-LABEL: test_mm256_slli_si256
1305 // CHECK: shufflevector <32 x i8> zeroinitializer, <32 x i8> %{{.*}}, <32 x i32> <i32 13, i32 14, i32 15, i32 32, i32 33, i32 34, i32 35, i32 36, i32 37, i32 38, i32 39, i32 40, i32 41, i32 42, i32 43, i32 44, i32 29, i32 30, i32 31, i32 48, i32 49, i32 50, i32 51, i32 52, i32 53, i32 54, i32 55, i32 56, i32 57, i32 58, i32 59, i32 60>
1306 return _mm256_slli_si256(a, 3);
1307 }
1308 TEST_CONSTEXPR(match_v32qi(_mm256_slli_si256(((__m256i)(__v32qi){1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32}), 3), 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0, 0, 0, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29));
1309 TEST_CONSTEXPR(match_v32qi(_mm256_slli_si256(((__m256i)(__v32qi){1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32}), 16), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
1310
1311 __m128i test_mm_sllv_epi32(__m128i a, __m128i b) {
1312 // CHECK-LABEL: test_mm_sllv_epi32
1313 // CHECK: call <4 x i32> @llvm.x86.avx2.psllv.d(<4 x i32> %{{.*}}, <4 x i32> %{{.*}})
1314 return _mm_sllv_epi32(a, b);
1315 }
1316 TEST_CONSTEXPR(match_v4si(_mm_sllv_epi32((__m128i)(__v4si){1, -2, 3, -4}, (__m128i)(__v4si){1, 2, 3, -4}), 2, -8, 24, 0));
1317
1318 __m256i test_mm256_sllv_epi32(__m256i a, __m256i b) {
1319 // CHECK-LABEL: test_mm256_sllv_epi32
1320 // CHECK: call <8 x i32> @llvm.x86.avx2.psllv.d.256(<8 x i32> %{{.*}}, <8 x i32> %{{.*}})
1321 return _mm256_sllv_epi32(a, b);
1322 }
1323 TEST_CONSTEXPR(match_v8si(_mm256_sllv_epi32((__m256i)(__v8si){1, -2, 3, -4, 5, -6, 7, -8}, (__m256i)(__v8si){1, 2, 3, 4, -17, 31, 33, 29}), 2, -8, 24, -64, 0, 0, 0, 0));
1324
1325 __m128i test_mm_sllv_epi64(__m128i a, __m128i b) {
1326 // CHECK-LABEL: test_mm_sllv_epi64
1327 // CHECK: call {{.*}}<2 x i64> @llvm.x86.avx2.psllv.q(<2 x i64> %{{.*}}, <2 x i64> %{{.*}})
1328 return _mm_sllv_epi64(a, b);
1329 }
1330 TEST_CONSTEXPR(match_m128i(_mm_sllv_epi64((__m128i)(__v2di){1, -3}, (__m128i)(__v2di){8, 63}), 256, 0x8000000000000000ULL));
1331
1332 __m256i test_mm256_sllv_epi64(__m256i a, __m256i b) {
1333 // CHECK-LABEL: test_mm256_sllv_epi64
1334 // CHECK: call {{.*}}<4 x i64> @llvm.x86.avx2.psllv.q.256(<4 x i64> %{{.*}}, <4 x i64> %{{.*}})
1335 return _mm256_sllv_epi64(a, b);
1336 }
1337 TEST_CONSTEXPR(match_m256i(_mm256_sllv_epi64((__m256i)(__v4di){1, -2, 3, -4}, (__m256i)(__v4di){1, 2, 3, -4}), 2, -8, 24, 0));
1338
1339 __m256i test_mm256_sra_epi16(__m256i a, __m128i b) {
1340 // CHECK-LABEL: test_mm256_sra_epi16
1341 // CHECK: call <16 x i16> @llvm.x86.avx2.psra.w(<16 x i16> %{{.*}}, <8 x i16> %{{.*}})
1342 return _mm256_sra_epi16(a, b);
1343 }
1344 TEST_CONSTEXPR(match_v16hi(_mm256_sra_epi16((__m256i)(__v16hi){-32768, 32767, -3, -2, -1, 0, 1, 2, -32768, 32767, -3, -2, -1, 0, 1, 2}, (__m128i)(__v8hi){1, 0, 0, 0, 0, 0, 0, 0}), -16384, 16383, -2, -1, -1, 0, 0, 1, -16384, 16383, -2, -1, -1, 0, 0, 1));
1345 TEST_CONSTEXPR(match_v16hi(_mm256_sra_epi16((__m256i)(__v16hi){-32768, 32767, -3, -2, -1, 0, 1, 2, -32768, 32767, -3, -2, -1, 0, 1, 2}, (__m128i)(__v8hi){16, 0, 0, 0, 0, 0, 0, 0}), -1, 0, -1, -1, -1, 0, 0, 0, -1, 0, -1, -1, -1, 0, 0, 0));
1346 TEST_CONSTEXPR(match_v16hi(_mm256_sra_epi16((__m256i)(__v16hi){-32768, 32767, -3, -2, -1, 0, 1, 2, -32768, 32767, -3, -2, -1, 0, 1, 2}, (__m128i)(__v8hi){0, 1, 0, 0, 0, 0, 0, 0}), -1, 0, -1, -1, -1, 0, 0, 0, -1, 0, -1, -1, -1, 0, 0, 0));
1347 TEST_CONSTEXPR(match_v16hi(_mm256_sra_epi16((__m256i)(__v16hi){-32768, 32767, -3, -2, -1, 0, 1, 2, -32768, 32767, -3, -2, -1, 0, 1, 2}, (__m128i)(__v8hi){0, 0, 1, 0, 0, 0, 0, 0}), -1, 0, -1, -1, -1, 0, 0, 0, -1, 0, -1, -1, -1, 0, 0, 0));
1348 TEST_CONSTEXPR(match_v16hi(_mm256_sra_epi16((__m256i)(__v16hi){-32768, 32767, -3, -2, -1, 0, 1, 2, -32768, 32767, -3, -2, -1, 0, 1, 2}, (__m128i)(__v8hi){0, 0, 0, 1, 0, 0, 0, 0}), -1, 0, -1, -1, -1, 0, 0, 0, -1, 0, -1, -1, -1, 0, 0, 0));
1349 TEST_CONSTEXPR(match_v16hi(_mm256_sra_epi16((__m256i)(__v16hi){-32768, 32767, -3, -2, -1, 0, 1, 2, -32768, 32767, -3, -2, -1, 0, 1, 2}, (__m128i)(__v8hi){1, 0, 0, 0, 1, 1, 1, 1}), -16384, 16383, -2, -1, -1, 0, 0, 1, -16384, 16383, -2, -1, -1, 0, 0, 1));
1350
1351 __m256i test_mm256_sra_epi32(__m256i a, __m128i b) {
1352 // CHECK-LABEL: test_mm256_sra_epi32
1353 // CHECK: call <8 x i32> @llvm.x86.avx2.psra.d(<8 x i32> %{{.*}}, <4 x i32> %{{.*}})
1354 return _mm256_sra_epi32(a, b);
1355 }
1356 TEST_CONSTEXPR(match_v8si(_mm256_sra_epi32((__m256i)(__v8si){-32768, 32767, -3, -2, -1, 0, 1, 2}, (__m128i)(__v4si){1, 0, 0, 0}), -16384, 16383, -2, -1, -1, 0, 0, 1));
1357 TEST_CONSTEXPR(match_v8si(_mm256_sra_epi32((__m256i)(__v8si){-32768, 32767, -3, -2, -1, 0, 1, 2}, (__m128i)(__v4si){32, 0, 0, 0}), -1, 0, -1, -1, -1, 0, 0, 0));
1358 TEST_CONSTEXPR(match_v8si(_mm256_sra_epi32((__m256i)(__v8si){-32768, 32767, -3, -2, -1, 0, 1, 2}, (__m128i)(__v4si){0, 1, 0, 0}), -1, 0, -1, -1, -1, 0, 0, 0));
1359 TEST_CONSTEXPR(match_v8si(_mm256_sra_epi32((__m256i)(__v8si){-32768, 32767, -3, -2, -1, 0, 1, 2}, (__m128i)(__v4si){1, 0, 1, 1}), -16384, 16383, -2, -1, -1, 0, 0, 1));
1360
1361 __m256i test_mm256_srai_epi16(__m256i a) {
1362 // CHECK-LABEL: test_mm256_srai_epi16
1363 // CHECK: call <16 x i16> @llvm.x86.avx2.psrai.w(<16 x i16> %{{.*}}, i32 %{{.*}})
1364 return _mm256_srai_epi16(a, 3);
1365 }
1366 TEST_CONSTEXPR(match_v16hi(_mm256_srai_epi16((__m256i)(__v16hi){-32768, 32767, -3, -2, -1, 0, 1, 2, -32768, 32767, -3, -2, -1, 0, 1, 2}, 1), -16384, 16383, -2, -1, -1, 0, 0, 1, -16384, 16383, -2, -1, -1, 0, 0, 1));
1367
1368 __m256i test_mm256_srai_epi16_2(__m256i a, int b) {
1369 // CHECK-LABEL: test_mm256_srai_epi16_2
1370 // CHECK: call <16 x i16> @llvm.x86.avx2.psrai.w(<16 x i16> %{{.*}}, i32 %{{.*}})
1371 return _mm256_srai_epi16(a, b);
1372 }
1373
1374 __m256i test_mm256_srai_epi32(__m256i a) {
1375 // CHECK-LABEL: test_mm256_srai_epi32
1376 // CHECK: call <8 x i32> @llvm.x86.avx2.psrai.d(<8 x i32> %{{.*}}, i32 %{{.*}})
1377 return _mm256_srai_epi32(a, 3);
1378 }
1379 TEST_CONSTEXPR(match_v8si(_mm256_srai_epi32((__m256i)(__v8si){-32768, 32767, -3, -2, -1, 0, 1, 2}, 1), -16384, 16383, -2, -1, -1, 0, 0, 1));
1380
1381 __m256i test_mm256_srai_epi32_2(__m256i a, int b) {
1382 // CHECK-LABEL: test_mm256_srai_epi32_2
1383 // CHECK: call <8 x i32> @llvm.x86.avx2.psrai.d(<8 x i32> %{{.*}}, i32 %{{.*}})
1384 return _mm256_srai_epi32(a, b);
1385 }
1386
1387 __m128i test_mm_srav_epi32(__m128i a, __m128i b) {
1388 // CHECK-LABEL: test_mm_srav_epi32
1389 // CHECK: call <4 x i32> @llvm.x86.avx2.psrav.d(<4 x i32> %{{.*}}, <4 x i32> %{{.*}})
1390 return _mm_srav_epi32(a, b);
1391 }
1392 TEST_CONSTEXPR(match_v4si(_mm_srav_epi32((__m128i)(__v4si){1, -2, 3, -4}, (__m128i)(__v4si){1, 2, 3, -4}), 0, -1, 0, -1));
1393
1394 __m256i test_mm256_srav_epi32(__m256i a, __m256i b) {
1395 // CHECK-LABEL: test_mm256_srav_epi32
1396 // CHECK: call <8 x i32> @llvm.x86.avx2.psrav.d.256(<8 x i32> %{{.*}}, <8 x i32> %{{.*}})
1397 return _mm256_srav_epi32(a, b);
1398 }
1399 TEST_CONSTEXPR(match_v8si(_mm256_srav_epi32((__m256i)(__v8si){1, -2, 3, -4, 5, -6, 7, -8}, (__m256i)(__v8si){1, 2, 3, 4, -17, 31, 33, 29}), 0, -1, 0, -1, 0, -1, 0, -1));
1400
1401 __m256i test_mm256_srl_epi16(__m256i a, __m128i b) {
1402 // CHECK-LABEL: test_mm256_srl_epi16
1403 // CHECK: call <16 x i16> @llvm.x86.avx2.psrl.w(<16 x i16> %{{.*}}, <8 x i16> %{{.*}})
1404 return _mm256_srl_epi16(a, b);
1405 }
1406 TEST_CONSTEXPR(match_v16hi(_mm256_srl_epi16((__m256i)(__v16hi){0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, (__m128i)(__v8hi){1, 0, 0, 0, 0, 0, 0, 0}), 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7));
1407 TEST_CONSTEXPR(match_v16hi(_mm256_srl_epi16((__m256i)(__v16hi){0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, (__m128i)(__v8hi){16, 0, 0, 0, 0, 0, 0, 0}), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
1408 TEST_CONSTEXPR(match_v16hi(_mm256_srl_epi16((__m256i)(__v16hi){0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, (__m128i)(__v8hi){0, 1, 0, 0, 0, 0, 0, 0}), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
1409 TEST_CONSTEXPR(match_v16hi(_mm256_srl_epi16((__m256i)(__v16hi){0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, (__m128i)(__v8hi){0, 0, 1, 0, 0, 0, 0, 0}), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
1410 TEST_CONSTEXPR(match_v16hi(_mm256_srl_epi16((__m256i)(__v16hi){0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, (__m128i)(__v8hi){0, 0, 0, 1, 0, 0, 0, 0}), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
1411 TEST_CONSTEXPR(match_v16hi(_mm256_srl_epi16((__m256i)(__v16hi){0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, (__m128i)(__v8hi){1, 0, 0, 0, 1, 1, 1, 1}), 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7));
1412
1413 __m256i test_mm256_srl_epi32(__m256i a, __m128i b) {
1414 // CHECK-LABEL: test_mm256_srl_epi32
1415 // CHECK:call <8 x i32> @llvm.x86.avx2.psrl.d(<8 x i32> %{{.*}}, <4 x i32> %{{.*}})
1416 return _mm256_srl_epi32(a, b);
1417 }
1418 TEST_CONSTEXPR(match_v8si(_mm256_srl_epi32((__m256i)(__v8si){0, 1, 2, 3, 4, 5, 6, 7}, (__m128i)(__v4si){1, 0, 0, 0}), 0, 0, 1, 1, 2, 2, 3, 3));
1419 TEST_CONSTEXPR(match_v8si(_mm256_srl_epi32((__m256i)(__v8si){0, 1, 2, 3, 4, 5, 6, 7}, (__m128i)(__v4si){32, 0, 0, 0}), 0, 0, 0, 0, 0, 0, 0, 0));
1420 TEST_CONSTEXPR(match_v8si(_mm256_srl_epi32((__m256i)(__v8si){0, 1, 2, 3, 4, 5, 6, 7}, (__m128i)(__v4si){0, 1, 0, 0}), 0, 0, 0, 0, 0, 0, 0, 0));
1421 TEST_CONSTEXPR(match_v8si(_mm256_srl_epi32((__m256i)(__v8si){0, 1, 2, 3, 4, 5, 6, 7}, (__m128i)(__v4si){1, 0, 1, 1}), 0, 0, 1, 1, 2, 2, 3, 3));
1422
1423 __m256i test_mm256_srl_epi64(__m256i a, __m128i b) {
1424 // CHECK-LABEL: test_mm256_srl_epi64
1425 // CHECK: call {{.*}}<4 x i64> @llvm.x86.avx2.psrl.q(<4 x i64> %{{.*}}, <2 x i64> %{{.*}})
1426 return _mm256_srl_epi64(a, b);
1427 }
1428 TEST_CONSTEXPR(match_v4di(_mm256_srl_epi64((__m256i)(__v4di){0, 1, 2, 3}, (__m128i)(__v2di){1, 0}), 0, 0, 1, 1));
1429 TEST_CONSTEXPR(match_v4di(_mm256_srl_epi64((__m256i)(__v4di){0, 1, 2, 3}, (__m128i)(__v2di){64, 0}), 0, 0, 0, 0));
1430 TEST_CONSTEXPR(match_v4di(_mm256_srl_epi64((__m256i)(__v4di){0, 1, 2, 3}, (__m128i)(__v2di){1, 1}), 0, 0, 1, 1));
1431
1432 __m256i test_mm256_srli_epi16(__m256i a) {
1433 // CHECK-LABEL: test_mm256_srli_epi16
1434 // CHECK: call <16 x i16> @llvm.x86.avx2.psrli.w(<16 x i16> %{{.*}}, i32 %{{.*}})
1435 return _mm256_srli_epi16(a, 3);
1436 }
1437 TEST_CONSTEXPR(match_v16hi(_mm256_srli_epi16((__m256i)(__v16hi){0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, 1), 0, 0x0, 0x1, 0x1, 0x2, 0x2, 0x3, 0x3, 0x4, 0x4, 0x5, 0x5, 0x6, 0x6, 0x7, 0x7));
1438
1439 __m256i test_mm256_srli_epi16_2(__m256i a, int b) {
1440 // CHECK-LABEL: test_mm256_srli_epi16_2
1441 // CHECK: call <16 x i16> @llvm.x86.avx2.psrli.w(<16 x i16> %{{.*}}, i32 %{{.*}})
1442 return _mm256_srli_epi16(a, b);
1443 }
1444
1445 __m256i test_mm256_srli_epi32(__m256i a) {
1446 // CHECK-LABEL: test_mm256_srli_epi32
1447 // CHECK: call <8 x i32> @llvm.x86.avx2.psrli.d(<8 x i32> %{{.*}}, i32 %{{.*}})
1448 return _mm256_srli_epi32(a, 3);
1449 }
1450 TEST_CONSTEXPR(match_v8si(_mm256_srli_epi32((__m256i)(__v8si){0, 1, 2, 3, 4, 5, 6, 7}, 31), 0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0));
1451
1452 __m256i test_mm256_srli_epi32_2(__m256i a, int b) {
1453 // CHECK-LABEL: test_mm256_srli_epi32_2
1454 // CHECK: call <8 x i32> @llvm.x86.avx2.psrli.d(<8 x i32> %{{.*}}, i32 %{{.*}})
1455 return _mm256_srli_epi32(a, b);
1456 }
1457
1458 __m256i test_mm256_srli_epi64(__m256i a) {
1459 // CHECK-LABEL: test_mm256_srli_epi64
1460 // CHECK: call {{.*}}<4 x i64> @llvm.x86.avx2.psrli.q(<4 x i64> %{{.*}}, i32 %{{.*}})
1461 return _mm256_srli_epi64(a, 3);
1462 }
1463 TEST_CONSTEXPR(match_v4di(_mm256_srli_epi64((__m256i)(__v4di){0, 1, 2, 3}, 33), 0, 0x0, 0x0, 0x0));
1464
1465 __m256i test_mm256_srli_epi64_2(__m256i a, int b) {
1466 // CHECK-LABEL: test_mm256_srli_epi64_2
1467 // CHECK: call {{.*}}<4 x i64> @llvm.x86.avx2.psrli.q(<4 x i64> %{{.*}}, i32 %{{.*}})
1468 return _mm256_srli_epi64(a, b);
1469 }
1470
1471 __m256i test_mm256_srli_si256(__m256i a) {
1472 // CHECK-LABEL: test_mm256_srli_si256
1473 // CHECK: shufflevector <32 x i8> %{{.*}}, <32 x i8> zeroinitializer, <32 x i32> <i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 32, i32 33, i32 34, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31, i32 48, i32 49, i32 50>
1474 return _mm256_srli_si256(a, 3);
1475 }
1476 TEST_CONSTEXPR(match_v32qi(_mm256_srli_si256(((__m256i)(__v32qi){1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32}), 3), 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 0, 0, 0, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 0, 0, 0));
1477 TEST_CONSTEXPR(match_v32qi(_mm256_srli_si256(((__m256i)(__v32qi){1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32}), 16), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
1478
1479 __m128i test_mm_srlv_epi32(__m128i a, __m128i b) {
1480 // CHECK-LABEL: test_mm_srlv_epi32
1481 // CHECK: call <4 x i32> @llvm.x86.avx2.psrlv.d(<4 x i32> %{{.*}}, <4 x i32> %{{.*}})
1482 return _mm_srlv_epi32(a, b);
1483 }
1484 TEST_CONSTEXPR(match_v4si(_mm_srlv_epi32((__m128i)(__v4si){1, -2, 3, -4}, (__m128i)(__v4si){1, 2, 3, -4}), 0, 1073741823, 0, 0));
1485
1486 __m256i test_mm256_srlv_epi32(__m256i a, __m256i b) {
1487 // CHECK-LABEL: test_mm256_srlv_epi32
1488 // CHECK: call <8 x i32> @llvm.x86.avx2.psrlv.d.256(<8 x i32> %{{.*}}, <8 x i32> %{{.*}})
1489 return _mm256_srlv_epi32(a, b);
1490 }
1491 TEST_CONSTEXPR(match_v8si(_mm256_srlv_epi32((__m256i)(__v8si){1, -2, 3, -4, 5, -6, 7, -8}, (__m256i)(__v8si){1, 2, 3, 4, -17, 31, 33, 29}), 0, 1073741823, 0, 268435455, 0, 1, 0, 7));
1492
1493 __m128i test_mm_srlv_epi64(__m128i a, __m128i b) {
1494 // CHECK-LABEL: test_mm_srlv_epi64
1495 // CHECK: call {{.*}}<2 x i64> @llvm.x86.avx2.psrlv.q(<2 x i64> %{{.*}}, <2 x i64> %{{.*}})
1496 return _mm_srlv_epi64(a, b);
1497 }
1498 TEST_CONSTEXPR(match_m128i(_mm_srlv_epi64((__m128i)(__v2di){1, -3}, (__m128i)(__v2di){8, 63}), 0, 1));
1499
1500 __m256i test_mm256_srlv_epi64(__m256i a, __m256i b) {
1501 // CHECK-LABEL: test_mm256_srlv_epi64
1502 // CHECK: call {{.*}}<4 x i64> @llvm.x86.avx2.psrlv.q.256(<4 x i64> %{{.*}}, <4 x i64> %{{.*}})
1503 return _mm256_srlv_epi64(a, b);
1504 }
1505 TEST_CONSTEXPR(match_m256i(_mm256_srlv_epi64((__m256i)(__v4di){1, -2, 3, -4}, (__m256i)(__v4di){1, 2, 3, -4}), 0, 0x3FFFFFFFFFFFFFFFULL, 0, 0));
1506
1507 __m256i test_mm256_stream_load_si256(__m256i const *a) {
1508 // CHECK-LABEL: test_mm256_stream_load_si256
1509 // CHECK: load <4 x i64>, ptr %{{.*}}, align 32, !nontemporal
1510 return _mm256_stream_load_si256(a);
1511 }
1512
1513 __m256i test_mm256_stream_load_si256_void(const void *a) {
1514 // CHECK-LABEL: test_mm256_stream_load_si256_void
1515 // CHECK: load <4 x i64>, ptr %{{.*}}, align 32, !nontemporal
1516 return _mm256_stream_load_si256(a);
1517 }
1518
1519 __m256i test_mm256_sub_epi8(__m256i a, __m256i b) {
1520 // CHECK-LABEL: test_mm256_sub_epi8
1521 // CHECK: sub <32 x i8>
1522 return _mm256_sub_epi8(a, b);
1523 }
1524
1525 TEST_CONSTEXPR(match_v32qi(_mm256_sub_epi8((__m256i)(__v32qs){ -64, -65, 66, 67, 68, -69, -70, -71, -72, 73, 74, -75, 76, 77, -78, 79, -80, 81, 82, -83, 84, -85, 86, 87, -88, -89, -90, 91, -92, 93, 94, 95}, (__m256i)(__v32qs){ -1, -2, 3, -4, 5, -6, 7, 8, 9, -10, 11, -12, 13, 14, 15, 16, -17, 18, 19, 20, -21, 22, -23, -24, 25, 26, -27, -28, -29, 30, -31, 32}), -63, -63, 63, 71, 63, -63, -77, -79, -81, 83, 63, -63, 63, 63, -93, 63, -63, 63, 63, -103, 105, -107, 109, 111, -113, -115, -63, 119, -63, 63, 125, 63));
1526
1527 __m256i test_mm256_sub_epi16(__m256i a, __m256i b) {
1528 // CHECK-LABEL: test_mm256_sub_epi16
1529 // CHECK: sub <16 x i16>
1530 return _mm256_sub_epi16(a, b);
1531 }
1532
1533 TEST_CONSTEXPR(match_v16hi(_mm256_sub_epi16((__m256i)(__v16hi){ -32, -33, 34, -35, -36, 37, -38, -39, -40, -41, -42, 43, -44, -45, 46, 47}, (__m256i)(__v16hi){ -1, 2, 3, -4, 5, -6, 7, 8, 9, 10, -11, -12, -13, 14, -15, -16}), -31, -35, 31, -31, -41, 43, -45, -47, -49, -51, -31, 55, -31, -59, 61, 63));
1534
1535 __m256i test_mm256_sub_epi32(__m256i a, __m256i b) {
1536 // CHECK-LABEL: test_mm256_sub_epi32
1537 // CHECK: sub <8 x i32>
1538 return _mm256_sub_epi32(a, b);
1539 }
1540
1541 TEST_CONSTEXPR(match_v8si(_mm256_sub_epi32((__m256i)(__v8si){ 16, 17, 18, -19, 20, -21, 22, 23}, (__m256i)(__v8si){ -1, 2, 3, 4, 5, 6, 7, 8}), 17, 15, 15, -23, 15, -27, 15, 15));
1542
1543 __m256i test_mm256_sub_epi64(__m256i a, __m256i b) {
1544 // CHECK-LABEL: test_mm256_sub_epi64
1545 // CHECK: sub <4 x i64>
1546 return _mm256_sub_epi64(a, b);
1547 }
1548
1549 TEST_CONSTEXPR(match_v4di(_mm256_sub_epi64((__m256i)(__v4di){ 8, -9, 10, 11}, (__m256i)(__v4di){ -1, -2, 3, 4}), 9, -7, 7, 7));
1550
1551 __m256i test_mm256_subs_epi8(__m256i a, __m256i b) {
1552 // CHECK-LABEL: test_mm256_subs_epi8
1553 // CHECK: call <32 x i8> @llvm.ssub.sat.v32i8(<32 x i8> %{{.*}}, <32 x i8> %{{.*}})
1554 return _mm256_subs_epi8(a, b);
1555 }
1556 TEST_CONSTEXPR(match_v32qi(_mm256_subs_epi8((__m256i)(__v32qs){0, +1, +2, +3, +4, +5, +6, +7, +8, +9, +10, +11, +12, +13, +14, +15, +100, +50, -100, +20, +80, -50, +120, -20, -100, -50, +100, -20, -80, +50, -120, +20}, (__m256i)(__v32qs){0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -50, -80, +50, -110, -60, +30, -20, +10, -50, -80, +50, -110, -60, +30, -20, +10}), 0, +2, +4, +6, +8, +10, +12, +14, +16, +18, +20, +22, +24, +26, +28, +30, +127, +127, -128, +127, +127, -80, +127, -30, -50, +30, +50, +90, -20, +20, -100, +10));
1557
1558 __m256i test_mm256_subs_epi16(__m256i a, __m256i b) {
1559 // CHECK-LABEL: test_mm256_subs_epi16
1560 // CHECK: call <16 x i16> @llvm.ssub.sat.v16i16(<16 x i16> %{{.*}}, <16 x i16> %{{.*}})
1561 return _mm256_subs_epi16(a, b);
1562 }
1563 TEST_CONSTEXPR(match_v16hi(_mm256_subs_epi16((__m256i)(__v16hi){0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, +32000, -32000, +32000, -32000}, (__m256i)(__v16hi){0, +1, +2, +3, +4, +5, +6, +7, +8, +9, +10, +11, -800, +800, +800, -800}),0, -2, -4, -6, -8, -10, -12, -14, -16, -18, -20, -22, +32767, -32768, +31200, -31200));
1564
1565 __m256i test_mm256_subs_epu8(__m256i a, __m256i b) {
1566 // CHECK-LABEL: test_mm256_subs_epu8
1567 // CHECK-NOT: call <32 x i8> @llvm.x86.avx2.psubus.b(<32 x i8> %{{.*}}, <32 x i8> %{{.*}})
1568 // CHECK: call <32 x i8> @llvm.usub.sat.v32i8(<32 x i8> %{{.*}}, <32 x i8> %{{.*}})
1569 return _mm256_subs_epu8(a, b);
1570 }
1571 TEST_CONSTEXPR(match_v32qu(_mm256_subs_epu8((__m256i)(__v32qu){0, 0, 0, 0, +64, +64, +64, +64, +64, +64, +127, +127, +127, +127, +127, +127, +128, +128, +128, +128, +128, +128, +192, +192, +192, +192, +192, +192, +255, +255, +255, +255}, (__m256i)(__v32qu){0, +127, +128, +255, 0, +64, +127, +128, +192, +255, 0, +64, +127, +128, +192, +255, 0, +64, +127, +128, +192, +255, 0, +64, +127, +128, +192, +255, 0, +127, +128, +255}), 0, 0, 0, 0, +64, 0, 0, 0, 0, 0, +127, +63, 0, 0, 0, 0, +128, +64, +1, 0, 0, 0, +192, +128, +65, +64, 0, 0, +255, +128, +127, 0));
1572
1573 __m256i test_mm256_subs_epu16(__m256i a, __m256i b) {
1574 // CHECK-LABEL: test_mm256_subs_epu16
1575 // CHECK-NOT: call <16 x i16> @llvm.x86.avx2.psubus.w(<16 x i16> %{{.*}}, <16 x i16> %{{.*}})
1576 // CHECK: call <16 x i16> @llvm.usub.sat.v16i16(<16 x i16> %{{.*}}, <16 x i16> %{{.*}})
1577 return _mm256_subs_epu16(a, b);
1578 }
1579 TEST_CONSTEXPR(match_v16hu(_mm256_subs_epu16((__m256i)(__v16hu){0, 0, 0, 0, +32767, +32767, +32767, +32767, +32768, +32768, +32768, +32768, +65535, +65535, +65535, +65535}, (__m256i)(__v16hu){0, +32767, +32768, +65535, 0, +32767, +32768, +65535, 0, +32767, +32768, +65535, 0, +32767, +32768, +65535}), 0, 0, 0, 0, +32767, 0, 0, 0, +32768, +1, 0, 0, +65535, +32768, +32767, 0));
1580
1581 __m256i test_mm256_unpackhi_epi8(__m256i a, __m256i b) {
1582 // CHECK-LABEL: test_mm256_unpackhi_epi8
1583 // CHECK: shufflevector <32 x i8> %{{.*}}, <32 x i8> %{{.*}}, <32 x i32> <i32 8, i32 40, i32 9, i32 41, i32 10, i32 42, i32 11, i32 43, i32 12, i32 44, i32 13, i32 45, i32 14, i32 46, i32 15, i32 47, i32 24, i32 56, i32 25, i32 57, i32 26, i32 58, i32 27, i32 59, i32 28, i32 60, i32 29, i32 61, i32 30, i32 62, i32 31, i32 63>
1584 return _mm256_unpackhi_epi8(a, b);
1585 }
1586 TEST_CONSTEXPR(match_v32qi(_mm256_unpackhi_epi8((__m256i)(__v32qi){0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31}, (__m256i)(__v32qi){32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63}), 8, 40, 9, 41, 10, 42, 11, 43, 12, 44, 13, 45, 14, 46, 15, 47, 24, 56, 25, 57, 26, 58, 27, 59, 28, 60, 29, 61, 30, 62, 31, 63));
1587
1588 __m256i test_mm256_unpackhi_epi16(__m256i a, __m256i b) {
1589 // CHECK-LABEL: test_mm256_unpackhi_epi16
1590 // CHECK: shufflevector <16 x i16> %{{.*}}, <16 x i16> %{{.*}}, <16 x i32> <i32 4, i32 20, i32 5, i32 21, i32 6, i32 22, i32 7, i32 23, i32 12, i32 28, i32 13, i32 29, i32 14, i32 30, i32 15, i32 31>
1591 return _mm256_unpackhi_epi16(a, b);
1592 }
1593 TEST_CONSTEXPR(match_v16hi(_mm256_unpackhi_epi16((__m256i)(__v16hi){0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, (__m256i)(__v16hi){16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31}), 4, 20, 5, 21, 6, 22, 7, 23, 12, 28, 13, 29, 14, 30, 15, 31));
1594
1595 __m256i test_mm256_unpackhi_epi32(__m256i a, __m256i b) {
1596 // CHECK-LABEL: test_mm256_unpackhi_epi32
1597 // CHECK: shufflevector <8 x i32> %{{.*}}, <8 x i32> %{{.*}}, <8 x i32> <i32 2, i32 10, i32 3, i32 11, i32 6, i32 14, i32 7, i32 15>
1598 return _mm256_unpackhi_epi32(a, b);
1599 }
1600 TEST_CONSTEXPR(match_v8si(_mm256_unpackhi_epi32((__m256i)(__v8si){0, 1, 2, 3, 4, 5, 6, 7}, (__m256i)(__v8si){8, 9, 10, 11, 12, 13, 14, 15}), 2, 10, 3, 11, 6, 14, 7, 15));
1601
1602 __m256i test_mm256_unpackhi_epi64(__m256i a, __m256i b) {
1603 // CHECK-LABEL: test_mm256_unpackhi_epi64
1604 // CHECK: shufflevector <4 x i64> %{{.*}}, <4 x i64> %{{.*}}, <4 x i32> <i32 1, i32 5, i32 3, i32 7>
1605 return _mm256_unpackhi_epi64(a, b);
1606 }
1607 TEST_CONSTEXPR(match_v4di(_mm256_unpackhi_epi64((__m256i)(__v4di){0, 1, 2, 3}, (__m256i)(__v4di){ 4, 5, 6, 7}), 1, 5, 3, 7));
1608
1609 __m256i test_mm256_unpacklo_epi8(__m256i a, __m256i b) {
1610 // CHECK-LABEL: test_mm256_unpacklo_epi8
1611 // CHECK: shufflevector <32 x i8> %{{.*}}, <32 x i8> %{{.*}}, <32 x i32> <i32 0, i32 32, i32 1, i32 33, i32 2, i32 34, i32 3, i32 35, i32 4, i32 36, i32 5, i32 37, i32 6, i32 38, i32 7, i32 39, i32 16, i32 48, i32 17, i32 49, i32 18, i32 50, i32 19, i32 51, i32 20, i32 52, i32 21, i32 53, i32 22, i32 54, i32 23, i32 55>
1612 return _mm256_unpacklo_epi8(a, b);
1613 }
1614 TEST_CONSTEXPR(match_v32qi(_mm256_unpacklo_epi8((__m256i)(__v32qi){0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31}, (__m256i)(__v32qi){32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63}), 0, 32, 1, 33, 2, 34, 3, 35, 4, 36, 5, 37, 6, 38, 7, 39, 16, 48, 17, 49, 18, 50, 19, 51, 20, 52, 21, 53, 22, 54, 23, 55));
1615
1616 __m256i test_mm256_unpacklo_epi16(__m256i a, __m256i b) {
1617 // CHECK-LABEL: test_mm256_unpacklo_epi16
1618 // CHECK: shufflevector <16 x i16> %{{.*}}, <16 x i16> %{{.*}}, <16 x i32> <i32 0, i32 16, i32 1, i32 17, i32 2, i32 18, i32 3, i32 19, i32 8, i32 24, i32 9, i32 25, i32 10, i32 26, i32 11, i32 27>
1619 return _mm256_unpacklo_epi16(a, b);
1620 }
1621 TEST_CONSTEXPR(match_v16hi(_mm256_unpacklo_epi16((__m256i)(__v16hi){0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, (__m256i)(__v16hi){16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31}), 0, 16, 1, 17, 2, 18, 3, 19, 8, 24, 9, 25, 10, 26, 11, 27));
1622
1623 __m256i test_mm256_unpacklo_epi32(__m256i a, __m256i b) {
1624 // CHECK-LABEL: test_mm256_unpacklo_epi32
1625 // CHECK: shufflevector <8 x i32> %{{.*}}, <8 x i32> %{{.*}}, <8 x i32> <i32 0, i32 8, i32 1, i32 9, i32 4, i32 12, i32 5, i32 13>
1626 return _mm256_unpacklo_epi32(a, b);
1627 }
1628 TEST_CONSTEXPR(match_v8si(_mm256_unpacklo_epi32((__m256i)(__v8si){0, 1, 2, 3, 4, 5, 6, 7}, (__m256i)(__v8si){ 8, 9, 10, 11, 12, 13, 14, 15}), 0, 8, 1, 9, 4, 12, 5, 13));
1629
1630 __m256i test_mm256_unpacklo_epi64(__m256i a, __m256i b) {
1631 // CHECK-LABEL: test_mm256_unpacklo_epi64
1632 // CHECK: shufflevector <4 x i64> %{{.*}}, <4 x i64> %{{.*}}, <4 x i32> <i32 0, i32 4, i32 2, i32 6>
1633 return _mm256_unpacklo_epi64(a, b);
1634 }
1635 TEST_CONSTEXPR(match_v4di(_mm256_unpacklo_epi64((__m256i)(__v4di){0, 1, 2, 3}, (__m256i)(__v4di){ 4, 5, 6, 7}), 0, 4, 2, 6));
1636
1637 __m256i test_mm256_xor_si256(__m256i a, __m256i b) {
1638 // CHECK-LABEL: test_mm256_xor_si256
1639 // CHECK: xor <4 x i64>
1640 return _mm256_xor_si256(a, b);
1641 }
1642 TEST_CONSTEXPR(match_v4di(_mm256_xor_si256((__m256i)(__v4di){0, -1, 0, -1}, (__m256i)(__v4di){0, 0, -1, -1}), 0, -1, -1, 0));