Clang Project

clang_source_code/test/Sema/builtins-x86.c
1// RUN: %clang_cc1 -triple=x86_64-apple-darwin -fsyntax-only -verify %s
2
3typedef long long __m128i __attribute__((__vector_size__(16)));
4typedef float __m128 __attribute__((__vector_size__(16)));
5typedef double __m128d __attribute__((__vector_size__(16)));
6
7typedef long long __m256i __attribute__((__vector_size__(32)));
8typedef float __m256 __attribute__((__vector_size__(32)));
9typedef double __m256d __attribute__((__vector_size__(32)));
10
11typedef long long __m512i __attribute__((__vector_size__(64)));
12typedef float __m512 __attribute__((__vector_size__(64)));
13typedef double __m512d __attribute__((__vector_size__(64)));
14
15typedef unsigned char __mmask8;
16typedef unsigned short __mmask16;
17typedef unsigned int __mmask32;
18
19void call_x86_32_builtins(void) {
20  (void)__builtin_ia32_readeflags_u32();                             // expected-error{{this builtin is only available on 32-bit targets}}
21  (void)__builtin_ia32_writeeflags_u32(4);                           // expected-error{{this builtin is only available on 32-bit targets}}
22}
23
24__m128 test__builtin_ia32_cmpps(__m128 __a, __m128 __b) {
25  return __builtin_ia32_cmpps(__a, __b, 32); // expected-error {{argument value 32 is outside the valid range [0, 31]}}
26}
27
28__m128d test__builtin_ia32_cmppd(__m128d __a, __m128d __b) {
29  return __builtin_ia32_cmppd(__a, __b, 32); // expected-error {{argument value 32 is outside the valid range [0, 31]}}
30}
31
32__m128 test__builtin_ia32_cmpss(__m128 __a, __m128 __b) {
33  return __builtin_ia32_cmpss(__a, __b, 32); // expected-error {{argument value 32 is outside the valid range [0, 31]}}
34}
35
36__m128d test__builtin_ia32_cmpsd(__m128d __a, __m128d __b) {
37  return __builtin_ia32_cmpsd(__a, __b, 32); // expected-error {{argument value 32 is outside the valid range [0, 31]}}
38}
39
40__mmask16 test__builtin_ia32_cmpps512_mask(__m512d __a, __m512d __b) {
41  return __builtin_ia32_cmpps512_mask(__a, __b, 32, -1, 4); // expected-error {{argument value 32 is outside the valid range [0, 31]}}
42}
43
44__mmask8 test__builtin_ia32_cmppd512_mask(__m512d __a, __m512d __b) {
45  return __builtin_ia32_cmppd512_mask(__a, __b, 32, -1, 4); // expected-error {{argument value 32 is outside the valid range [0, 31]}}
46}
47
48__m128i test__builtin_ia32_vpcomub(__m128i __a, __m128i __b) {
49  return __builtin_ia32_vpcomub(__a, __b, 8); // expected-error {{argument value 8 is outside the valid range [0, 7]}}
50}
51
52__m128i test__builtin_ia32_vpcomuw(__m128i __a, __m128i __b) {
53  return __builtin_ia32_vpcomuw(__a, __b, 8); // expected-error {{argument value 8 is outside the valid range [0, 7]}}
54}
55
56__m128i test__builtin_ia32_vpcomud(__m128i __a, __m128i __b) {
57  return __builtin_ia32_vpcomud(__a, __b, 8); // expected-error {{argument value 8 is outside the valid range [0, 7]}}
58}
59
60__m128i test__builtin_ia32_vpcomuq(__m128i __a, __m128i __b) {
61  return __builtin_ia32_vpcomuq(__a, __b, 8); // expected-error {{argument value 8 is outside the valid range [0, 7]}}
62}
63
64__m128i test__builtin_ia32_vpcomb(__m128i __a, __m128i __b) {
65  return __builtin_ia32_vpcomub(__a, __b, 8); // expected-error {{argument value 8 is outside the valid range [0, 7]}}
66}
67
68__m128i test__builtin_ia32_vpcomw(__m128i __a, __m128i __b) {
69  return __builtin_ia32_vpcomuw(__a, __b, 8); // expected-error {{argument value 8 is outside the valid range [0, 7]}}
70}
71
72__m128i test__builtin_ia32_vpcomd(__m128i __a, __m128i __b) {
73  return __builtin_ia32_vpcomud(__a, __b, 8); // expected-error {{argument value 8 is outside the valid range [0, 7]}}
74}
75
76__m128i test__builtin_ia32_vpcomq(__m128i __a, __m128i __b) {
77  return __builtin_ia32_vpcomuq(__a, __b, 8); // expected-error {{argument value 8 is outside the valid range [0, 7]}}
78}
79
80__mmask16 test__builtin_ia32_cmpps512_mask_rounding(__m512 __a, __m512 __b, __mmask16 __u) {
81  return __builtin_ia32_cmpps512_mask(__a, __b, 0, __u, 0); // expected-error {{invalid rounding argument}}
82}
83
84__m128i test_mm_mask_i32gather_epi32(__m128i a, int const *b, __m128i c, __m128i mask) {
85  return __builtin_ia32_gatherd_d(a, b, c, mask, 5); // expected-error {{scale argument must be 1, 2, 4, or 8}}
86}
87
88void _mm512_mask_prefetch_i32gather_ps(__m512i index, __mmask16 mask, int const *addr) {
89  __builtin_ia32_gatherpfdps(mask, index, addr, 5, 1); // expected-error {{scale argument must be 1, 2, 4, or 8}}
90}
91
92void _mm512_mask_prefetch_i32gather_ps_2(__m512i index, __mmask16 mask, int const *addr) {
93  __builtin_ia32_gatherpfdps(mask, index, addr, 1, 1); // expected-error {{argument value 1 is outside the valid range [2, 3]}}
94}
95
96__m512i test_mm512_shldi_epi64(__m512i __A, __m512i __B) {
97  return __builtin_ia32_vpshldq512(__A, __B, 1024); // expected-error {{argument value 1024 is outside the valid range [0, 255]}}
98}
99
100__m512i test_mm512_shldi_epi32(__m512i __A, __m512i __B) {
101  return __builtin_ia32_vpshldd512(__A, __B, 1024); // expected-error {{argument value 1024 is outside the valid range [0, 255]}}
102}
103
104__m512i test_mm512_shldi_epi16(__m512i __A, __m512i __B) {
105  return __builtin_ia32_vpshldw512(__A, __B, 1024); // expected-error {{argument value 1024 is outside the valid range [0, 255]}}
106}
107
108__m512i test_mm512_shrdi_epi64(__m512i __A, __m512i __B) {
109  return __builtin_ia32_vpshrdq512(__A, __B, 1024); // expected-error {{argument value 1024 is outside the valid range [0, 255]}}
110}
111
112__m512i test_mm512_shrdi_epi32(__m512i __A, __m512i __B) {
113  return __builtin_ia32_vpshrdd512(__A, __B, 1024); // expected-error {{argument value 1024 is outside the valid range [0, 255]}}
114}
115
116__m512i test_mm512_shrdi_epi16(__m512i __A, __m512i __B) {
117  return __builtin_ia32_vpshrdw512(__A, __B, 1024); // expected-error {{argument value 1024 is outside the valid range [0, 255]}}
118}
119
120__m256i test_mm256_shldi_epi64(__m256i __A, __m256i __B) {
121  return __builtin_ia32_vpshldq256(__A, __B, 1024); // expected-error {{argument value 1024 is outside the valid range [0, 255]}}
122}
123
124__m128i test_mm128_shldi_epi64( __m128i __A, __m128i __B) {
125  return __builtin_ia32_vpshldq128(__A, __B, 1024); // expected-error {{argument value 1024 is outside the valid range [0, 255]}}
126}
127
128__m256i test_mm256_shldi_epi32(__m256i __A, __m256i __B) {
129  return __builtin_ia32_vpshldd256(__A, __B, 1024); // expected-error {{argument value 1024 is outside the valid range [0, 255]}}
130}
131
132__m128i test_mm128_shldi_epi32(__m128i __A, __m128i __B) {
133  return __builtin_ia32_vpshldd128(__A, __B, 1024); // expected-error {{argument value 1024 is outside the valid range [0, 255]}}
134}
135
136__m256i test_mm256_shldi_epi16( __m256i __A, __m256i __B) {
137  return __builtin_ia32_vpshldw256(__A, __B, 1024); // expected-error {{argument value 1024 is outside the valid range [0, 255]}}
138}
139
140__m128i test_mm128_shldi_epi16(__m128i __A, __m128i __B) {
141  return __builtin_ia32_vpshldw128(__A, __B, 1024); // expected-error {{argument value 1024 is outside the valid range [0, 255]}}
142}
143
144__m256i test_mm256_shrdi_epi64(__m256i __A, __m256i __B) {
145  return __builtin_ia32_vpshrdq256(__A, __B, 1024); // expected-error {{argument value 1024 is outside the valid range [0, 255]}}
146}
147
148__m128i test_mm128_shrdi_epi64(__m128i __A, __m128i __B) {
149  return __builtin_ia32_vpshrdq128(__A, __B, 1024); // expected-error {{argument value 1024 is outside the valid range [0, 255]}}
150}
151
152__m256i test_mm256_shrdi_epi32(__m256i __A, __m256i __B) {
153  return __builtin_ia32_vpshrdd256(__A, __B, 1024); // expected-error {{argument value 1024 is outside the valid range [0, 255]}}
154}
155
156__m128i test_mm128_shrdi_epi32(__m128i __A, __m128i __B) {
157  return __builtin_ia32_vpshrdd128(__A, __B, 1024); // expected-error {{argument value 1024 is outside the valid range [0, 255]}}
158}
159
160__m256i test_mm256_shrdi_epi16(__m256i __A, __m256i __B) {
161  return __builtin_ia32_vpshrdw256(__A, __B, 1024); // expected-error {{argument value 1024 is outside the valid range [0, 255]}}
162}
163
164__m128i test_mm128_shrdi_epi16(__m128i __A, __m128i __B) {
165  return __builtin_ia32_vpshrdw128(__A, __B, 1024); // expected-error {{argument value 1024 is outside the valid range [0, 255]}}
166}
167