Debian Codegraph @

clang/test/CIR/CodeGenBuiltins/X86/avx512vl-builtins.c

raw
1 // RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx512f -target-feature +avx512vl -fclangir -emit-cir -o %t.cir -Wall -Werror -Wsign-conversion
2 // RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
3 // RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx512f -target-feature +avx512vl -fclangir -emit-llvm -o %t.ll -Wall -Werror -Wsign-conversion
4 // RUN: FileCheck --check-prefixes=LLVM --input-file=%t.ll %s
5 // RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx512f -target-feature +avx512vl -emit-llvm -o %t.ll -Wall -Werror -Wsign-conversion
6 // RUN: FileCheck --check-prefixes=OGCG --input-file=%t.ll %s
7
8 #include <immintrin.h>
9
10 __m128d test_mm_mmask_i64gather_pd(__m128d __v1_old, __mmask8 __mask, __m128i __index, void const *__addr) {
11 // CIR-LABEL: test_mm_mmask_i64gather_pd
12 // CIR: cir.call_llvm_intrinsic "x86.avx512.mask.gather3div2.df"
13
14 // LLVM-LABEL: @test_mm_mmask_i64gather_pd
15 // LLVM: @llvm.x86.avx512.mask.gather3div2.df
16
17 // OGCG-LABEL: @test_mm_mmask_i64gather_pd
18 // OGCG: @llvm.x86.avx512.mask.gather3div2.df
19 return _mm_mmask_i64gather_pd(__v1_old, __mask, __index, __addr, 2);
20 }
21
22 __m128i test_mm_mmask_i64gather_epi64(__m128i __v1_old, __mmask8 __mask, __m128i __index, void const *__addr) {
23 // CIR-LABEL: test_mm_mmask_i64gather_epi64
24 // CIR: cir.call_llvm_intrinsic "x86.avx512.mask.gather3div2.di"
25
26 // LLVM-LABEL: @test_mm_mmask_i64gather_epi64
27 // LLVM: @llvm.x86.avx512.mask.gather3div2.di
28
29 // OGCG-LABEL: @test_mm_mmask_i64gather_epi64
30 // OGCG: @llvm.x86.avx512.mask.gather3div2.di
31 return _mm_mmask_i64gather_epi64(__v1_old, __mask, __index, __addr, 2);
32 }
33
34 __m256d test_mm256_mmask_i64gather_pd(__m256d __v1_old, __mmask8 __mask, __m256i __index, void const *__addr) {
35 // CIR-LABEL: test_mm256_mmask_i64gather_pd
36 // CIR: cir.call_llvm_intrinsic "x86.avx512.mask.gather3div4.df"
37
38 // LLVM-LABEL: @test_mm256_mmask_i64gather_pd
39 // LLVM: @llvm.x86.avx512.mask.gather3div4.df
40
41 // OGCG-LABEL: @test_mm256_mmask_i64gather_pd
42 // OGCG: @llvm.x86.avx512.mask.gather3div4.df
43 return _mm256_mmask_i64gather_pd(__v1_old, __mask, __index, __addr, 2);
44 }
45
46 __m256i test_mm256_mmask_i64gather_epi64(__m256i __v1_old, __mmask8 __mask, __m256i __index, void const *__addr) {
47 // CIR-LABEL: test_mm256_mmask_i64gather_epi64
48 // CIR: cir.call_llvm_intrinsic "x86.avx512.mask.gather3div4.di"
49
50 // LLVM-LABEL: @test_mm256_mmask_i64gather_epi64
51 // LLVM: @llvm.x86.avx512.mask.gather3div4.di
52
53 // OGCG-LABEL: @test_mm256_mmask_i64gather_epi64
54 // OGCG: @llvm.x86.avx512.mask.gather3div4.di
55 return _mm256_mmask_i64gather_epi64(__v1_old, __mask, __index, __addr, 2);
56 }
57
58 __m128 test_mm_mmask_i64gather_ps(__m128 __v1_old, __mmask8 __mask, __m128i __index, void const *__addr) {
59 // CIR-LABEL: test_mm_mmask_i64gather_ps
60 // CIR: cir.call_llvm_intrinsic "x86.avx512.mask.gather3div4.sf"
61
62 // LLVM-LABEL: @test_mm_mmask_i64gather_ps
63 // LLVM: @llvm.x86.avx512.mask.gather3div4.sf
64
65 // OGCG-LABEL: @test_mm_mmask_i64gather_ps
66 // OGCG: @llvm.x86.avx512.mask.gather3div4.sf
67 return _mm_mmask_i64gather_ps(__v1_old, __mask, __index, __addr, 2);
68 }
69
70 __m128i test_mm_mmask_i64gather_epi32(__m128i __v1_old, __mmask8 __mask, __m128i __index, void const *__addr) {
71 // CIR-LABEL: test_mm_mmask_i64gather_epi32
72 // CIR: cir.call_llvm_intrinsic "x86.avx512.mask.gather3div4.si"
73
74 // LLVM-LABEL: @test_mm_mmask_i64gather_epi32
75 // LLVM: @llvm.x86.avx512.mask.gather3div4.si
76
77 // OGCG-LABEL: @test_mm_mmask_i64gather_epi32
78 // OGCG: @llvm.x86.avx512.mask.gather3div4.si
79 return _mm_mmask_i64gather_epi32(__v1_old, __mask, __index, __addr, 2);
80 }
81
82 __m128 test_mm256_mmask_i64gather_ps(__m128 __v1_old, __mmask8 __mask, __m256i __index, void const *__addr) {
83 // CIR-LABEL: test_mm256_mmask_i64gather_ps
84 // CIR: cir.call_llvm_intrinsic "x86.avx512.mask.gather3div8.sf"
85
86 // LLVM-LABEL: @test_mm256_mmask_i64gather_ps
87 // LLVM: @llvm.x86.avx512.mask.gather3div8.sf
88
89 // OGCG-LABEL: @test_mm256_mmask_i64gather_ps
90 // OGCG: @llvm.x86.avx512.mask.gather3div8.sf
91 return _mm256_mmask_i64gather_ps(__v1_old, __mask, __index, __addr, 2);
92 }
93
94 __m128i test_mm256_mmask_i64gather_epi32(__m128i __v1_old, __mmask8 __mask, __m256i __index, void const *__addr) {
95 // CIR-LABEL: test_mm256_mmask_i64gather_epi32
96 // CIR: cir.call_llvm_intrinsic "x86.avx512.mask.gather3div8.si"
97
98 // LLVM-LABEL: @test_mm256_mmask_i64gather_epi32
99 // LLVM: @llvm.x86.avx512.mask.gather3div8.si
100
101 // OGCG-LABEL: @test_mm256_mmask_i64gather_epi32
102 // OGCG: @llvm.x86.avx512.mask.gather3div8.si
103 return _mm256_mmask_i64gather_epi32(__v1_old, __mask, __index, __addr, 2);
104 }
105
106 __m128d test_mm_mask_i32gather_pd(__m128d __v1_old, __mmask8 __mask, __m128i __index, void const *__addr) {
107 // CIR-LABEL: test_mm_mask_i32gather_pd
108 // CIR: cir.call_llvm_intrinsic "x86.avx512.mask.gather3siv2.df"
109
110 // LLVM-LABEL: @test_mm_mask_i32gather_pd
111 // LLVM: @llvm.x86.avx512.mask.gather3siv2.df
112
113 // OGCG-LABEL: @test_mm_mask_i32gather_pd
114 // OGCG: @llvm.x86.avx512.mask.gather3siv2.df
115 return _mm_mmask_i32gather_pd(__v1_old, __mask, __index, __addr, 2);
116 }
117
118 __m128i test_mm_mask_i32gather_epi64(__m128i __v1_old, __mmask8 __mask, __m128i __index, void const *__addr) {
119 // CIR-LABEL: test_mm_mask_i32gather_epi64
120 // CIR: cir.call_llvm_intrinsic "x86.avx512.mask.gather3siv2.di"
121
122 // LLVM-LABEL: @test_mm_mask_i32gather_epi64
123 // LLVM: @llvm.x86.avx512.mask.gather3siv2.di
124
125 // OGCG-LABEL: @test_mm_mask_i32gather_epi64
126 // OGCG: @llvm.x86.avx512.mask.gather3siv2.di
127 return _mm_mmask_i32gather_epi64(__v1_old, __mask, __index, __addr, 2);
128 }
129
130 __m256d test_mm256_mask_i32gather_pd(__m256d __v1_old, __mmask8 __mask, __m128i __index, void const *__addr) {
131 // CIR-LABEL: test_mm256_mask_i32gather_pd
132 // CIR: cir.call_llvm_intrinsic "x86.avx512.mask.gather3siv4.df"
133
134 // LLVM-LABEL: @test_mm256_mask_i32gather_pd
135 // LLVM: @llvm.x86.avx512.mask.gather3siv4.df
136
137 // OGCG-LABEL: @test_mm256_mask_i32gather_pd
138 // OGCG: @llvm.x86.avx512.mask.gather3siv4.df
139 return _mm256_mmask_i32gather_pd(__v1_old, __mask, __index, __addr, 2);
140 }
141
142 __m256i test_mm256_mask_i32gather_epi64(__m256i __v1_old, __mmask8 __mask, __m128i __index, void const *__addr) {
143 // CIR-LABEL: test_mm256_mask_i32gather_epi64
144 // CIR: cir.call_llvm_intrinsic "x86.avx512.mask.gather3siv4.di"
145
146 // LLVM-LABEL: @test_mm256_mask_i32gather_epi64
147 // LLVM: @llvm.x86.avx512.mask.gather3siv4.di
148
149 // OGCG-LABEL: @test_mm256_mask_i32gather_epi64
150 // OGCG: @llvm.x86.avx512.mask.gather3siv4.di
151 return _mm256_mmask_i32gather_epi64(__v1_old, __mask, __index, __addr, 2);
152 }
153
154 __m128 test_mm_mask_i32gather_ps(__m128 __v1_old, __mmask8 __mask, __m128i __index, void const *__addr) {
155 // CIR-LABEL: test_mm_mask_i32gather_ps
156 // CIR: cir.call_llvm_intrinsic "x86.avx512.mask.gather3siv4.sf"
157
158 // LLVM-LABEL: @test_mm_mask_i32gather_ps
159 // LLVM: @llvm.x86.avx512.mask.gather3siv4.sf
160
161 // OGCG-LABEL: @test_mm_mask_i32gather_ps
162 // OGCG: @llvm.x86.avx512.mask.gather3siv4.sf
163 return _mm_mmask_i32gather_ps(__v1_old, __mask, __index, __addr, 2);
164 }
165
166 __m128i test_mm_mask_i32gather_epi32(__m128i __v1_old, __mmask8 __mask, __m128i __index, void const *__addr) {
167 // CIR-LABEL: test_mm_mask_i32gather_epi32
168 // CIR: cir.call_llvm_intrinsic "x86.avx512.mask.gather3siv4.si"
169
170 // LLVM-LABEL: @test_mm_mask_i32gather_epi32
171 // LLVM: @llvm.x86.avx512.mask.gather3siv4.si
172
173 // OGCG-LABEL: @test_mm_mask_i32gather_epi32
174 // OGCG: @llvm.x86.avx512.mask.gather3siv4.si
175 return _mm_mmask_i32gather_epi32(__v1_old, __mask, __index, __addr, 2);
176 }
177
178 __m256 test_mm256_mask_i32gather_ps(__m256 __v1_old, __mmask8 __mask, __m256i __index, void const *__addr) {
179 // CIR-LABEL: test_mm256_mask_i32gather_ps
180 // CIR: cir.call_llvm_intrinsic "x86.avx512.mask.gather3siv8.sf"
181
182 // LLVM-LABEL: @test_mm256_mask_i32gather_ps
183 // LLVM: @llvm.x86.avx512.mask.gather3siv8.sf
184
185 // OGCG-LABEL: @test_mm256_mask_i32gather_ps
186 // OGCG: @llvm.x86.avx512.mask.gather3siv8.sf
187 return _mm256_mmask_i32gather_ps(__v1_old, __mask, __index, __addr, 2);
188 }
189
190 __m256i test_mm256_mask_i32gather_epi32(__m256i __v1_old, __mmask8 __mask, __m256i __index, void const *__addr) {
191 // CIR-LABEL: test_mm256_mask_i32gather_epi32
192 // CIR: cir.call_llvm_intrinsic "x86.avx512.mask.gather3siv8.si"
193
194 // LLVM-LABEL: @test_mm256_mask_i32gather_epi32
195 // LLVM: @llvm.x86.avx512.mask.gather3siv8.si
196
197 // OGCG-LABEL: @test_mm256_mask_i32gather_epi32
198 // OGCG: @llvm.x86.avx512.mask.gather3siv8.si
199 return _mm256_mmask_i32gather_epi32(__v1_old, __mask, __index, __addr, 2);
200 }
201
202 __m128i test_mm_ror_epi32(__m128i __A) {
203 // CIR-LABEL: test_mm_ror_epi32
204 // CIR: cir.vec.splat %{{.*}} : !u32i, !cir.vector<4 x !u32i>
205 // CIR: cir.call_llvm_intrinsic "fshr" %{{.*}}: (!cir.vector<4 x !s32i>, !cir.vector<4 x !s32i>, !cir.vector<4 x !u32i>) -> !cir.vector<4 x !s32i>
206
207 // LLVM-LABEL: @test_mm_ror_epi32
208 // LLVM: %[[CASTED_VAR:.*]] = bitcast <2 x i64> %{{.*}} to <4 x i32>
209 // LLVM: call <4 x i32> @llvm.fshr.v4i32(<4 x i32> %[[CASTED_VAR]], <4 x i32> %[[CASTED_VAR]], <4 x i32> splat (i32 5))
210
211 // OGCG-LABEL: @test_mm_ror_epi32
212 // OGCG: %[[CASTED_VAR:.*]] = bitcast <2 x i64> %{{.*}} to <4 x i32>
213 // OGCG: call <4 x i32> @llvm.fshr.v4i32(<4 x i32> %[[CASTED_VAR]], <4 x i32> %[[CASTED_VAR]], <4 x i32> splat (i32 5))
214 return _mm_ror_epi32(__A, 5);
215 }
216
217 __m256i test_mm256_ror_epi32(__m256i __A) {
218 // CIR-LABEL: test_mm256_ror_epi32
219 // CIR: cir.vec.splat %{{.*}} : !u32i, !cir.vector<8 x !u32i>
220 // CIR: cir.call_llvm_intrinsic "fshr" %{{.*}}: (!cir.vector<8 x !s32i>, !cir.vector<8 x !s32i>, !cir.vector<8 x !u32i>) -> !cir.vector<8 x !s32i>
221
222 // LLVM-LABEL: @test_mm256_ror_epi32
223 // LLVM: %[[CASTED_VAR:.*]] = bitcast <4 x i64> %{{.*}} to <8 x i32>
224 // LLVM: call <8 x i32> @llvm.fshr.v8i32(<8 x i32> %[[CASTED_VAR]], <8 x i32> %[[CASTED_VAR]], <8 x i32> splat (i32 5))
225
226 // OGCG-LABEL: @test_mm256_ror_epi32
227 // OGCG: %[[CASTED_VAR:.*]] = bitcast <4 x i64> %{{.*}} to <8 x i32>
228 // OGCG: call <8 x i32> @llvm.fshr.v8i32(<8 x i32> %[[CASTED_VAR]], <8 x i32> %[[CASTED_VAR]], <8 x i32> splat (i32 5))
229 return _mm256_ror_epi32(__A, 5);
230 }
231
232 __m128i test_mm_ror_epi64(__m128i __A) {
233 // CIR-LABEL: test_mm_ror_epi64
234 // CIR: cir.vec.splat %{{.*}} : !u64i, !cir.vector<2 x !u64i>
235 // CIR: cir.call_llvm_intrinsic "fshr" %{{.*}}: (!cir.vector<2 x !s64i>, !cir.vector<2 x !s64i>, !cir.vector<2 x !u64i>) -> !cir.vector<2 x !s64i>
236
237 // LLVM-LABEL: @test_mm_ror_epi64
238 // LLVM: call <2 x i64> @llvm.fshr.v2i64(<2 x i64> %[[V:.*]], <2 x i64> %[[V]], <2 x i64> splat (i64 5))
239
240 // OGCG-LABEL: @test_mm_ror_epi64
241 // OGCG: call <2 x i64> @llvm.fshr.v2i64(<2 x i64> %[[V:.*]], <2 x i64> %[[V]], <2 x i64> splat (i64 5))
242 return _mm_ror_epi64(__A, 5);
243 }
244
245 __m256i test_mm256_ror_epi64(__m256i __A) {
246 // CIR-LABEL: test_mm256_ror_epi64
247 // CIR: cir.vec.splat %{{.*}} : !u64i, !cir.vector<4 x !u64i>
248 // CIR: cir.call_llvm_intrinsic "fshr" %{{.*}}: (!cir.vector<4 x !s64i>, !cir.vector<4 x !s64i>, !cir.vector<4 x !u64i>) -> !cir.vector<4 x !s64i>
249
250 // LLVM-LABEL: @test_mm256_ror_epi64
251 // LLVM: call <4 x i64> @llvm.fshr.v4i64(<4 x i64> %[[V:.*]], <4 x i64> %[[V]], <4 x i64> splat (i64 5))
252
253 // OGCG-LABEL: @test_mm256_ror_epi64
254 // OGCG: call <4 x i64> @llvm.fshr.v4i64(<4 x i64> %[[V:.*]], <4 x i64> %[[V]], <4 x i64> splat (i64 5))
255 return _mm256_ror_epi64(__A, 5);
256 }
257
258 __m256 test_mm256_insertf32x4(__m256 __A, __m128 __B) {
259 // CIR-LABEL: test_mm256_insertf32x4
260 // CIR: %{{.*}} = cir.vec.shuffle(%{{.*}}, %{{.*}} : !cir.vector<8 x !cir.float>) [#cir.int<0> : !s32i, #cir.int<1> : !s32i, #cir.int<2> : !s32i, #cir.int<3> : !s32i, #cir.int<8> : !s32i, #cir.int<9> : !s32i, #cir.int<10> : !s32i, #cir.int<11> : !s32i] : !cir.vector<8 x !cir.float>
261
262 // LLVM-LABEL: @test_mm256_insertf32x4
263 // LLVM: shufflevector <8 x float> %{{.*}}, <8 x float> %{{.*}}, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 8, i32 9, i32 10, i32 11>
264
265 // OGCG-LABEL: @test_mm256_insertf32x4
266 // OGCG: shufflevector <8 x float> %{{.*}}, <8 x float> %{{.*}}, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 8, i32 9, i32 10, i32 11>
267 return _mm256_insertf32x4(__A, __B, 1);
268 }
269
270 __m256i test_mm256_inserti32x4(__m256i __A, __m128i __B) {
271 // CIR-LABEL: test_mm256_inserti32x4
272 // CIR: %{{.*}} = cir.vec.shuffle(%{{.*}}, %{{.*}} : !cir.vector<8 x !s32i>) [#cir.int<0> : !s32i, #cir.int<1> : !s32i, #cir.int<2> : !s32i, #cir.int<3> : !s32i, #cir.int<8> : !s32i, #cir.int<9> : !s32i, #cir.int<10> : !s32i, #cir.int<11> : !s32i] : !cir.vector<8 x !s32i>
273
274 // LLVM-LABEL: @test_mm256_inserti32x4
275 // LLVM: shufflevector <8 x i32> %{{.*}}, <8 x i32> %{{.*}}, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 8, i32 9, i32 10, i32 11>
276
277 // OGCG-LABEL: @test_mm256_inserti32x4
278 // OGCG: shufflevector <8 x i32> %{{.*}}, <8 x i32> %{{.*}}, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 8, i32 9, i32 10, i32 11>
279 return _mm256_inserti32x4(__A, __B, 1);
280 }
281
282 __m128d test_mm_mask_expand_pd(__m128d __W, __mmask8 __U, __m128d __A) {
283 // CIR-LABEL: _mm_mask_expand_pd
284 // CIR: %[[MASK:.*]] = cir.cast bitcast {{.*}} : !u8i -> !cir.vector<8 x !cir.int<s, 1>>
285 // CIR: %[[SHUF:.*]] = cir.vec.shuffle(%[[MASK]], %[[MASK]] : !cir.vector<8 x !cir.int<s, 1>>) [#cir.int<0> : !s32i, #cir.int<1> : !s32i] : !cir.vector<2 x !cir.int<s, 1>>
286
287 // LLVM-LABEL: test_mm_mask_expand_pd
288 // LLVM: %[[BC:.*]] = bitcast i8 %{{.*}} to <8 x i1>
289 // LLVM: %[[SHUF:.*]] = shufflevector <8 x i1> %[[BC]], <8 x i1> %[[BC]], <2 x i32> <i32 0, i32 1>
290
291 // OGCG-LABEL: test_mm_mask_expand_pd
292 // OGCG: %[[BC:.*]] = bitcast i8 %{{.*}} to <8 x i1>
293 // OGCG: %[[SHUF:.*]] = shufflevector <8 x i1> %[[BC]], <8 x i1> %[[BC]], <2 x i32> <i32 0, i32 1>
294
295 return _mm_mask_expand_pd(__W,__U,__A);
296 }
297
298 __m128d test_mm_maskz_expand_pd(__mmask8 __U, __m128d __A) {
299 // CIR-LABEL: _mm_maskz_expand_pd
300 // CIR: %[[MASK:.*]] = cir.cast bitcast {{.*}} : !u8i -> !cir.vector<8 x !cir.int<s, 1>>
301 // CIR: %[[SHUF:.*]] = cir.vec.shuffle(%[[MASK]], %[[MASK]] : !cir.vector<8 x !cir.int<s, 1>>) [#cir.int<0> : !s32i, #cir.int<1> : !s32i] : !cir.vector<2 x !cir.int<s, 1>>
302
303 // LLVM-LABEL: test_mm_maskz_expand_pd
304 // LLVM: %[[BC:.*]] = bitcast i8 %{{.*}} to <8 x i1>
305 // LLVM: %[[SHUF:.*]] = shufflevector <8 x i1> %[[BC]], <8 x i1> %[[BC]], <2 x i32> <i32 0, i32 1>
306
307 // OGCG-LABEL: test_mm_maskz_expand_pd
308 // OGCG: %[[BC:.*]] = bitcast i8 %{{.*}} to <8 x i1>
309 // OGCG: %[[SHUF:.*]] = shufflevector <8 x i1> %[[BC]], <8 x i1> %[[BC]], <2 x i32> <i32 0, i32 1>
310
311 return _mm_maskz_expand_pd(__U,__A);
312 }