Skip to content

Commit b6b6482

Browse files
authored
[Headers][X86] Add a test for MMX/SSE intrinsics (#105852)
Certain intrinsics map to builtins that require an immediate (literal) argument; make sure we report non-literal arguments. This has been kicking around downstream for a while, and the recent removal of the MMX builtins caused me to notice it again.
1 parent 4ea2c73 commit b6b6482

File tree

1 file changed

+387
-0
lines changed

1 file changed

+387
-0
lines changed
Lines changed: 387 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,387 @@
1+
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only \
2+
// RUN: -target-feature +f16c -target-feature +avx -target-feature +sse4a \
3+
// RUN: -target-feature +aes -target-feature +xop -target-feature +avx2 \
4+
// RUN: -target-feature +tbm -verify %s
5+
6+
// Error test cases where a variable is passed to intrinsics but an
7+
// immediate operand is required.
8+
9+
// Don't include mm_malloc.h, it's system specific.
10+
#define __MM_MALLOC_H
11+
12+
#include <x86intrin.h>
13+
14+
unsigned short check__cvtss_sh(float val, const int I) {
15+
return _cvtss_sh(val, I); // expected-error {{argument to '__builtin_ia32_vcvtps2ph' must be a constant integer}}
16+
}
17+
18+
__m128i check__mm_cvtps_ph(__m128 val, const int I) {
19+
return _mm_cvtps_ph(val, I); // expected-error {{argument to '__builtin_ia32_vcvtps2ph' must be a constant integer}}
20+
}
21+
22+
__m128i check__mm256_cvtps_ph(__m256 val, const int I) {
23+
return _mm256_cvtps_ph(val, I); // expected-error {{argument to '__builtin_ia32_vcvtps2ph256' must be a constant integer}}
24+
}
25+
26+
// SCE_ARCH begin: bug 16381
27+
void check__mm_slli_si128(__m128i a, const int count) {
28+
_mm_slli_si128(a, count); // expected-error {{argument to '__builtin_ia32_pslldqi128_byteshift' must be a constant integer}}
29+
}
30+
31+
void check__mm_srli_si128(__m128i a, const int count) {
32+
_mm_srli_si128(a, count); // expected-error {{argument to '__builtin_ia32_psrldqi128_byteshift' must be a constant integer}}
33+
}
34+
// SCE_ARCH end
35+
36+
void check__mm_shuffle_epi32(__m128i a, const int imm) {
37+
_mm_shuffle_epi32(a, imm); // expected-error {{argument to '__builtin_ia32_pshufd' must be a constant integer}}
38+
}
39+
40+
void check__mm_shufflelo_epi16(__m128i a, const int imm) {
41+
_mm_shufflelo_epi16(a, imm); // expected-error {{argument to '__builtin_ia32_pshuflw' must be a constant integer}}
42+
}
43+
44+
void check__mm_shufflehi_epi16(__m128i a, const int imm) {
45+
_mm_shufflehi_epi16(a, imm); // expected-error {{argument to '__builtin_ia32_pshufhw' must be a constant integer}}
46+
}
47+
48+
void check__mm_shuffle_pd(__m128d a, __m128d b, const int i) {
49+
_mm_shuffle_pd(a, b, i); // expected-error {{argument to '__builtin_ia32_shufpd' must be a constant integer}}
50+
}
51+
52+
void check__mm256_round_pd(__m256d a, const int b) {
53+
_mm256_round_pd(a, b); // expected-error {{argument to '__builtin_ia32_roundpd256' must be a constant integer}}
54+
}
55+
56+
void check__mm256_round_ps(__m256 a, const int b) {
57+
_mm256_round_ps(a, b); // expected-error {{argument to '__builtin_ia32_roundps256' must be a constant integer}}
58+
}
59+
60+
void check__mm_permute_pd(__m128d a, const int b) {
61+
_mm_permute_pd(a, b); // expected-error {{argument to '__builtin_ia32_vpermilpd' must be a constant integer}}
62+
}
63+
64+
void check__mm256_permute_pd(__m256d a, const int b) {
65+
_mm256_permute_pd(a, b); // expected-error {{argument to '__builtin_ia32_vpermilpd256' must be a constant integer}}
66+
}
67+
68+
void check__mm_permute_ps(__m128 a, const int b) {
69+
_mm_permute_ps(a, b); // expected-error {{argument to '__builtin_ia32_vpermilps' must be a constant integer}}
70+
}
71+
72+
void check__mm256_permute_ps(__m256 a, const int b) {
73+
_mm256_permute_ps(a, b); // expected-error {{argument to '__builtin_ia32_vpermilps256' must be a constant integer}}
74+
}
75+
76+
void check__mm256_permute2f128_pd(__m256d v1, __m256d v2, const char m) {
77+
_mm256_permute2f128_pd(v1, v2, m); // expected-error {{argument to '__builtin_ia32_vperm2f128_pd256' must be a constant integer}}
78+
}
79+
80+
void check__mm256_permute2f128_ps(__m256 v1, __m256 v2, const char m) {
81+
_mm256_permute2f128_ps(v1, v2, m); // expected-error {{argument to '__builtin_ia32_vperm2f128_ps256' must be a constant integer}}
82+
}
83+
84+
void check__mm256_permute2f128_si256(__m256i v1, __m256i v2, const char m) {
85+
_mm256_permute2f128_si256(v1, v2, m); // expected-error {{argument to '__builtin_ia32_vperm2f128_si256' must be a constant integer}}
86+
}
87+
88+
void check__m256_blend_pd(__m256d v1, __m256d v2, const char m) {
89+
_mm256_blend_pd(v1, v2, m); // expected-error {{argument to '__builtin_ia32_blendpd256' must be a constant integer}}
90+
}
91+
92+
void check__m256_blend_ps(__m256 v1, __m256 v2, const char m) {
93+
_mm256_blend_ps(v1, v2, m); // expected-error {{argument to '__builtin_ia32_blendps256' must be a constant integer}}
94+
}
95+
96+
void check__mm256_dp_ps(__m256 v1, __m256 v2, const char m) {
97+
_mm256_dp_ps(v1, v2, m); // expected-error {{argument to '__builtin_ia32_dpps256' must be a constant integer}}
98+
}
99+
100+
void check__m256_shuffle_ps(__m256 a, __m256 b, const int m) {
101+
_mm256_shuffle_ps(a, b, m); // expected-error {{argument to '__builtin_ia32_shufps256' must be a constant integer}}
102+
}
103+
104+
void check__m256_shuffle_pd(__m256d a, __m256d b, const int m) {
105+
_mm256_shuffle_pd(a, b, m); // expected-error {{argument to '__builtin_ia32_shufpd256' must be a constant integer}}
106+
}
107+
108+
void check__mm_cmp_pd(__m128d a, __m128d b, const int c) {
109+
_mm_cmp_pd(a, b, c); // expected-error {{argument to '__builtin_ia32_cmppd' must be a constant integer}}
110+
}
111+
112+
void check__mm_cmp_ps(__m128 a, __m128 b, const int c) {
113+
_mm_cmp_ps(a, b, c); // expected-error {{argument to '__builtin_ia32_cmpps' must be a constant integer}}
114+
}
115+
116+
void check__mm256_cmp_pd(__m256d a, __m256d b, const int c) {
117+
_mm256_cmp_pd(a, b, c); // expected-error {{argument to '__builtin_ia32_cmppd256' must be a constant integer}}
118+
}
119+
120+
void check__mm256_cmp_ps(__m256 a, __m256 b, const int c) {
121+
_mm256_cmp_ps(a, b, c); // expected-error {{argument to '__builtin_ia32_cmpps256' must be a constant integer}}
122+
}
123+
124+
void check__mm_cmp_sd(__m128d a, __m128d b, const int c) {
125+
_mm_cmp_sd(a, b, c); // expected-error {{argument to '__builtin_ia32_cmpsd' must be a constant integer}}
126+
}
127+
128+
void check__mm_cmp_ss(__m128 a, __m128 b, const int c) {
129+
_mm_cmp_ss(a, b, c); // expected-error {{argument to '__builtin_ia32_cmpss' must be a constant integer}}
130+
}
131+
132+
void check__mm256_extractf128_pd(__m256d a, const int o) {
133+
_mm256_extractf128_pd(a, o); // expected-error {{argument to '__builtin_ia32_vextractf128_pd256' must be a constant integer}}
134+
}
135+
136+
void check__mm256_extractf128_ps(__m256 a, const int o) {
137+
_mm256_extractf128_ps(a, o); // expected-error {{argument to '__builtin_ia32_vextractf128_ps256' must be a constant integer}}
138+
}
139+
140+
void check__mm256_extractf128_si256(__m256i a, const int o) {
141+
_mm256_extractf128_si256(a, o); // expected-error {{argument to '__builtin_ia32_vextractf128_si256' must be a constant integer}}
142+
}
143+
144+
void check__mm256_insertf128_pd(__m256d v1, __m128d v2, const int o) {
145+
_mm256_insertf128_pd(v1, v2, o); // expected-error {{argument to '__builtin_ia32_vinsertf128_pd256' must be a constant integer}}
146+
}
147+
148+
void check__mm256_insertf128_ps(__m256 v1, __m128 v2, const int o) {
149+
_mm256_insertf128_ps(v1, v2, o); // expected-error {{argument to '__builtin_ia32_vinsertf128_ps256' must be a constant integer}}
150+
}
151+
152+
void check__mm256_insertf128_si256(__m256i v1, __m128i v2, const int o) {
153+
_mm256_insertf128_si256(v1, v2, o); // expected-error {{argument to '__builtin_ia32_vinsertf128_si256' must be a constant integer}}
154+
}
155+
156+
void check__mm_round_ps(__m128 x, const int m) {
157+
_mm_round_ps(x, m); // expected-error {{argument to '__builtin_ia32_roundps' must be a constant integer}}
158+
}
159+
160+
void check__mm_round_ss(__m128 x, __m128 y, const int m) {
161+
_mm_round_ss(x, y, m); // expected-error {{argument to '__builtin_ia32_roundss' must be a constant integer}}
162+
}
163+
164+
void check__mm_round_pd(__m128d x, const int m) {
165+
_mm_round_pd(x, m); // expected-error {{argument to '__builtin_ia32_roundpd' must be a constant integer}}
166+
}
167+
168+
void check__mm_round_sd(__m128d x, __m128d y, const int m) {
169+
_mm_round_sd(x, y, m); // expected-error {{argument to '__builtin_ia32_roundsd' must be a constant integer}}
170+
}
171+
172+
void check__mm_blend_pd(__m128d v1, __m128d v2, const int m) {
173+
_mm_blend_pd(v1, v2, m); // expected-error {{argument to '__builtin_ia32_blendpd' must be a constant integer}}
174+
}
175+
176+
void check__mm_blend_ps(__m128 v1, __m128 v2, const int m) {
177+
_mm_blend_ps(v1, v2, m); // expected-error {{argument to '__builtin_ia32_blendps' must be a constant integer}}
178+
}
179+
180+
void check__mm_blend_epi16(__m128i v1, __m128i v2, const int m) {
181+
_mm_blend_epi16(v1, v2, m); // expected-error {{argument to '__builtin_ia32_pblendw128' must be a constant integer}}
182+
}
183+
184+
void check__mm_dp_ps(__m128 x, __m128 y, const int m) {
185+
_mm_dp_ps(x, y, m); // expected-error {{argument to '__builtin_ia32_dpps' must be a constant integer}}
186+
}
187+
188+
void check__mm_dp_pd(__m128d x, __m128d y, const int m) {
189+
_mm_dp_pd(x, y, m); // expected-error {{argument to '__builtin_ia32_dppd' must be a constant integer}}
190+
}
191+
192+
void check__mm_insert_ps(__m128 a, __m128 b, const int n) {
193+
_mm_insert_ps(a, b, n); // expected-error {{argument to '__builtin_ia32_insertps128' must be a constant integer}}
194+
}
195+
196+
void check__mm_mpsadbw_epu8(__m128i x, __m128i y, const int m) {
197+
_mm_mpsadbw_epu8(x, y, m); // expected-error {{argument to '__builtin_ia32_mpsadbw128' must be a constant integer}}
198+
}
199+
200+
void check__mm_cmpistrm(__m128 a, __m128 b, const int m) {
201+
_mm_cmpistrm(a, b, m); // expected-error {{argument to '__builtin_ia32_pcmpistrm128' must be a constant integer}}
202+
}
203+
204+
void check__mm_cmpistri(__m128i a, __m128i b, const int m) {
205+
_mm_cmpistri(a, b, m); // expected-error {{argument to '__builtin_ia32_pcmpistri128' must be a constant integer}}
206+
}
207+
208+
void check__mm_cmpestrm(__m128 a, int b, __m128 c, int d, const int m) {
209+
_mm_cmpestrm(a, b, c, d, m); // expected-error {{argument to '__builtin_ia32_pcmpestrm128' must be a constant integer}}
210+
}
211+
212+
void check__mm_cmpestri(__m128i a, int b, __m128i c, int d, const int m) {
213+
_mm_cmpestri(a, b, c, d, m); // expected-error {{argument to '__builtin_ia32_pcmpestri128' must be a constant integer}}
214+
}
215+
216+
void check__mm_alignr_epi8(__m128i a, __m128i b, const int n) {
217+
_mm_alignr_epi8(a, b, n); // expected-error {{argument to '__builtin_ia32_palignr128' must be a constant integer}}
218+
}
219+
220+
void check__mm_alignr_pi8(__m64 a, __m64 b, const int n) {
221+
_mm_alignr_pi8(a, b, n); // expected-error {{argument to '__builtin_ia32_psrldqi128_byteshift' must be a constant integer}}
222+
}
223+
224+
void check__mm_aeskeygenassist_si128(__m128 c, const int r) {
225+
_mm_aeskeygenassist_si128(c, r); // expected-error {{argument to '__builtin_ia32_aeskeygenassist128' must be a constant integer}}
226+
}
227+
228+
__m64 check__mm_shuffle_pi16(__m64 a, const int n) {
229+
return _mm_shuffle_pi16(a, n); // expected-error {{index for __builtin_shufflevector must be a constant integer}}
230+
}
231+
232+
void check__mm_shuffle_ps(__m128 a, __m128 b, const int m) {
233+
_mm_shuffle_ps(a, b, m); // expected-error {{argument to '__builtin_ia32_shufps' must be a constant integer}}
234+
}
235+
236+
void check__mm_com_epi8(__m128 a, __m128 b, const char c) {
237+
_mm_com_epi8(a, b, c); // expected-error {{argument to '__builtin_ia32_vpcomb' must be a constant integer}}
238+
}
239+
240+
void check__mm_com_epi16(__m128 a, __m128 b, const char c) {
241+
_mm_com_epi16(a, b, c); // expected-error {{argument to '__builtin_ia32_vpcomw' must be a constant integer}}
242+
}
243+
244+
void check__mm_com_epi32(__m128 a, __m128 b, const char c) {
245+
_mm_com_epi32(a, b, c); // expected-error {{argument to '__builtin_ia32_vpcomd' must be a constant integer}}
246+
}
247+
248+
void check__mm_com_epi64(__m128 a, __m128 b, const char c) {
249+
_mm_com_epi64(a, b, c); // expected-error {{argument to '__builtin_ia32_vpcomq' must be a constant integer}}
250+
}
251+
252+
void check__mm_com_epu8(__m128 a, __m128 b, const char c) {
253+
_mm_com_epu8(a, b, c); // expected-error {{argument to '__builtin_ia32_vpcomub' must be a constant integer}}
254+
}
255+
256+
void check__mm_com_epu16(__m128 a, __m128 b, const char c) {
257+
_mm_com_epu16(a, b, c); // expected-error {{argument to '__builtin_ia32_vpcomuw' must be a constant integer}}
258+
}
259+
260+
void check__mm_com_epu32(__m128 a, __m128 b, const char c) {
261+
_mm_com_epu32(a, b, c); // expected-error {{argument to '__builtin_ia32_vpcomud' must be a constant integer}}
262+
}
263+
264+
void check__mm_com_epu64(__m128 a, __m128 b, const char c) {
265+
_mm_com_epu64(a, b, c); // expected-error {{argument to '__builtin_ia32_vpcomuq' must be a constant integer}}
266+
}
267+
268+
void check__mm_permute2_pd(__m128d a, __m128d b, __m128d c, const char d) {
269+
_mm_permute2_pd(a, b, c, d); // expected-error {{argument to '__builtin_ia32_vpermil2pd' must be a constant integer}}
270+
}
271+
272+
void check__mm_permute2_ps(__m128 a, __m128 b, __m128 c, const char d) {
273+
_mm_permute2_ps(a, b, c, d); // expected-error {{argument to '__builtin_ia32_vpermil2ps' must be a constant integer}}
274+
}
275+
276+
void check__mm256_permute2_pd(__m256d a, __m256d b, __m256d c, const char d) {
277+
_mm256_permute2_pd(a, b, c, d); // expected-error {{argument to '__builtin_ia32_vpermil2pd256' must be a constant integer}}
278+
}
279+
280+
void check__mm256_permute2_ps(__m256 a, __m256 b, __m256 c, const char d) {
281+
_mm256_permute2_ps(a, b, c, d); // expected-error {{argument to '__builtin_ia32_vpermil2ps256' must be a constant integer}}
282+
}
283+
284+
void check__mm_roti_epi8(__m128 a, const char b) {
285+
_mm_roti_epi8(a, b); // expected-error {{argument to '__builtin_ia32_vprotbi' must be a constant integer}}
286+
}
287+
288+
void check__mm_roti_epi16(__m128 a, const char b) {
289+
_mm_roti_epi16(a, b); // expected-error {{argument to '__builtin_ia32_vprotwi' must be a constant integer}}
290+
}
291+
292+
void check__mm_roti_epi32(__m128 a, const char b) {
293+
_mm_roti_epi32(a, b); // expected-error {{argument to '__builtin_ia32_vprotdi' must be a constant integer}}
294+
}
295+
296+
void check__mm_roti_epi64(__m128 a, const char b) {
297+
_mm_roti_epi64(a, b); // expected-error {{argument to '__builtin_ia32_vprotqi' must be a constant integer}}
298+
}
299+
300+
void check__mm256_mpsadbw_epu8(__m256i a, __m256i b, const int c) {
301+
_mm256_mpsadbw_epu8(a, b, c); // expected-error {{argument to '__builtin_ia32_mpsadbw256' must be a constant integer}}
302+
}
303+
304+
void check__mm256_alignr_epi8(__m256i a, __m256i b, const int n) {
305+
_mm256_alignr_epi8(a, b, n); // expected-error {{argument to '__builtin_ia32_palignr256' must be a constant integer}}
306+
}
307+
308+
void check__mm256_blend_epi16(__m256i a, __m256i b, const int m) {
309+
_mm256_blend_epi16(a, b, m); // expected-error {{argument to '__builtin_ia32_pblendw256' must be a constant integer}}
310+
}
311+
312+
void check__mm256_slli_si256(__m256i a, const int count) {
313+
_mm256_slli_si256(a, count); // expected-error {{argument to '__builtin_ia32_pslldqi256_byteshift' must be a constant integer}}
314+
}
315+
316+
void check__mm256_shuffle_epi32(__m256i a, const int imm) {
317+
_mm256_shuffle_epi32(a, imm); // expected-error {{argument to '__builtin_ia32_pshufd256' must be a constant integer}}
318+
}
319+
320+
void check__mm256_shufflehi_epi16(__m256i a, const int imm) {
321+
_mm256_shufflehi_epi16(a, imm); // expected-error {{argument to '__builtin_ia32_pshufhw256' must be a constant integer}}
322+
}
323+
324+
void check__mm256_shufflelo_epi16(__m256i a, const int imm) {
325+
_mm256_shufflelo_epi16(a, imm); // expected-error {{argument to '__builtin_ia32_pshuflw256' must be a constant integer}}
326+
}
327+
328+
void check__mm_blend_epi32(__m128i a, __m128i b, const int m) {
329+
_mm_blend_epi32(a, b, m); // expected-error {{argument to '__builtin_ia32_pblendd128' must be a constant integer}}
330+
}
331+
332+
void check__mm256_blend_epi32(__m256i a, __m256i b, const int m) {
333+
_mm256_blend_epi32(a, b, m); // expected-error {{argument to '__builtin_ia32_pblendd256' must be a constant integer}}
334+
}
335+
336+
void check__mm256_permute4x64_pd(__m256d v, const int m) {
337+
_mm256_permute4x64_pd(v, m); // expected-error {{argument to '__builtin_ia32_permdf256' must be a constant integer}}
338+
}
339+
340+
void check__mm256_permute4x64_epi64(__m256i v, const int m) {
341+
_mm256_permute4x64_epi64(v, m); // expected-error {{argument to '__builtin_ia32_permdi256' must be a constant integer}}
342+
}
343+
344+
void check__mm256_permute2x128_si256(__m256i v1, __m256i v2, const int m) {
345+
_mm256_permute2x128_si256(v1, v2, m); // expected-error {{argument to '__builtin_ia32_permti256' must be a constant integer}}
346+
}
347+
348+
void check__mm256_extracti128_si256(__m256i v1, const int m) {
349+
_mm256_extracti128_si256(v1, m); // expected-error {{argument to '__builtin_ia32_extract128i256' must be a constant integer}}
350+
}
351+
352+
void check__mm256_inserti128_si256(__m256i v1, __m128i v2, const int m) {
353+
_mm256_inserti128_si256(v1, v2, m); // expected-error {{argument to '__builtin_ia32_insert128i256' must be a constant integer}}
354+
}
355+
356+
void check__mm256_srli_si256(__m256i a, int count) {
357+
_mm256_srli_si256(a, count); // expected-error {{argument to '__builtin_ia32_psrldqi256_byteshift' must be a constant integer}}
358+
}
359+
360+
int check__bextri_u32(int a, int b) {
361+
return __bextri_u32(a, b); // expected-error {{argument to '__builtin_ia32_bextri_u32' must be a constant integer}}
362+
}
363+
364+
int check__bextri_u64(long a, long b) {
365+
return __bextri_u64(a, b); // expected-error {{argument to '__builtin_ia32_bextri_u64' must be a constant integer}}
366+
}
367+
368+
int check___builtin_eh_return_data_regno(int a) {
369+
return __builtin_eh_return_data_regno(a); // expected-error {{argument to '__builtin_eh_return_data_regno' must be a constant integer}}
370+
}
371+
372+
void* check___builtin_frame_address(unsigned int a) {
373+
return __builtin_frame_address(a); // expected-error {{argument to '__builtin_frame_address' must be a constant integer}}
374+
}
375+
376+
void* check___builtin_return_address(unsigned int a) {
377+
return __builtin_return_address(a); // expected-error {{argument to '__builtin_return_address' must be a constant integer}}
378+
}
379+
380+
void check__mm_extracti_si64(__m128i a, const char len, const char id) {
381+
_mm_extracti_si64(a, len, id); // expected-error {{argument to '__builtin_ia32_extrqi' must be a constant integer}}
382+
}
383+
384+
void check__insert_si64(__m128 a, __m128 b, const char len, const char id) {
385+
_mm_inserti_si64(a, b, len, id); // expected-error {{argument to '__builtin_ia32_insertqi' must be a constant integer}}
386+
}
387+

0 commit comments

Comments
 (0)