1 /* Same as sse-14, except converted to use #pragma GCC option. */
2 /* { dg-do compile } */
3 /* { dg-options "-O0 -Werror-implicit-function-declaration -march=k8" } */
7 /* Test that the intrinsics compile with optimization. All of them
8 are defined as inline functions in {,x,e,p,t,s,w,a,b,i}mmintrin.h,
9 mm3dnow.h, fma4intrin.h, xopintrin.h, abmintrin.h, bmiintrin.h,
10 tbmintrin.h, lwpintrin.h, popcntintrin.h, fmaintrin.h and mm_malloc.h
11 that reference the proper builtin functions.
13 Defining away "extern" and "__inline" results in all of them being
14 compiled as proper functions. */
19 #define _CONCAT(x,y) x ## y
21 #define test_0(func, type, imm) \
22 type _CONCAT(_,func) (int const I) \
23 { return func (imm); }
25 #define test_1(func, type, op1_type, imm) \
26 type _CONCAT(_,func) (op1_type A, int const I) \
27 { return func (A, imm); }
29 #define test_1x(func, type, op1_type, imm1, imm2) \
30 type _CONCAT(_,func) (op1_type A, int const I, int const L) \
31 { return func (A, imm1, imm2); }
33 #define test_2(func, type, op1_type, op2_type, imm) \
34 type _CONCAT(_,func) (op1_type A, op2_type B, int const I) \
35 { return func (A, B, imm); }
37 #define test_2x(func, type, op1_type, op2_type, imm1, imm2) \
38 type _CONCAT(_,func) (op1_type A, op2_type B, int const I, int const L) \
39 { return func (A, B, imm1, imm2); }
41 #define test_3(func, type, op1_type, op2_type, op3_type, imm) \
42 type _CONCAT(_,func) (op1_type A, op2_type B, \
43 op3_type C, int const I) \
44 { return func (A, B, C, imm); }
46 #define test_4(func, type, op1_type, op2_type, op3_type, op4_type, imm) \
47 type _CONCAT(_,func) (op1_type A, op2_type B, \
48 op3_type C, op4_type D, int const I) \
49 { return func (A, B, C, D, imm); }
52 #ifndef DIFFERENT_PRAGMAS
53 #pragma GCC target ("sse4a,3dnow,avx,avx2,fma4,xop,aes,pclmul,popcnt,abm,lzcnt,bmi,bmi2,tbm,lwp,fsgsbase,rdrnd,f16c,rtm,rdseed,prfchw")
56 /* Following intrinsics require immediate arguments. They
57 are defined as macros for non-optimized compilations. */
59 /* mmintrin.h (MMX). */
60 #ifdef DIFFERENT_PRAGMAS
61 #pragma GCC target ("mmx")
65 /* mm3dnow.h (3DNOW). */
66 #ifdef DIFFERENT_PRAGMAS
67 #pragma GCC target ("3dnow")
71 /* xmmintrin.h (SSE). */
72 #ifdef DIFFERENT_PRAGMAS
73 #pragma GCC target ("sse")
75 #include <xmmintrin.h>
76 test_2 (_mm_shuffle_ps
, __m128
, __m128
, __m128
, 1)
77 test_1 (_mm_extract_pi16
, int, __m64
, 1)
78 test_1 (_m_pextrw
, int, __m64
, 1)
79 test_2 (_mm_insert_pi16
, __m64
, __m64
, int, 1)
80 test_2 (_m_pinsrw
, __m64
, __m64
, int, 1)
81 test_1 (_mm_shuffle_pi16
, __m64
, __m64
, 1)
82 test_1 (_m_pshufw
, __m64
, __m64
, 1)
83 test_1 (_mm_prefetch
, void, void *, _MM_HINT_NTA
)
85 /* emmintrin.h (SSE2). */
86 #ifdef DIFFERENT_PRAGMAS
87 #pragma GCC target ("sse2")
89 #include <emmintrin.h>
90 test_2 (_mm_shuffle_pd
, __m128d
, __m128d
, __m128d
, 1)
91 test_1 (_mm_srli_si128
, __m128i
, __m128i
, 1)
92 test_1 (_mm_slli_si128
, __m128i
, __m128i
, 1)
93 test_1 (_mm_extract_epi16
, int, __m128i
, 1)
94 test_2 (_mm_insert_epi16
, __m128i
, __m128i
, int, 1)
95 test_1 (_mm_shufflehi_epi16
, __m128i
, __m128i
, 1)
96 test_1 (_mm_shufflelo_epi16
, __m128i
, __m128i
, 1)
97 test_1 (_mm_shuffle_epi32
, __m128i
, __m128i
, 1)
99 /* pmmintrin.h (SSE3). */
100 #ifdef DIFFERENT_PRAGMAS
101 #pragma GCC target ("sse3")
103 #include <pmmintrin.h>
105 /* tmmintrin.h (SSSE3). */
106 #ifdef DIFFERENT_PRAGMAS
107 #pragma GCC target ("ssse3")
109 #include <tmmintrin.h>
110 test_2 (_mm_alignr_epi8
, __m128i
, __m128i
, __m128i
, 1)
111 test_2 (_mm_alignr_pi8
, __m64
, __m64
, __m64
, 1)
113 /* ammintrin.h (SSE4A). */
114 #ifdef DIFFERENT_PRAGMAS
115 #pragma GCC target ("sse4a")
117 #include <ammintrin.h>
118 test_1x (_mm_extracti_si64
, __m128i
, __m128i
, 1, 1)
119 test_2x (_mm_inserti_si64
, __m128i
, __m128i
, __m128i
, 1, 1)
121 /* Note, nmmintrin.h includes smmintrin.h, and smmintrin.h
122 checks for the #ifdef. So just set the option to SSE4.2. */
123 #ifdef DIFFERENT_PRAGMAS
124 #pragma GCC target ("sse4.2")
126 #include <nmmintrin.h>
127 /* smmintrin.h (SSE4.2). */
128 test_1 (_mm_round_pd
, __m128d
, __m128d
, 1)
129 test_1 (_mm_round_ps
, __m128
, __m128
, 1)
130 test_2 (_mm_round_sd
, __m128d
, __m128d
, __m128d
, 1)
131 test_2 (_mm_round_ss
, __m128
, __m128
, __m128
, 1)
133 test_2 (_mm_blend_epi16
, __m128i
, __m128i
, __m128i
, 1)
134 test_2 (_mm_blend_ps
, __m128
, __m128
, __m128
, 1)
135 test_2 (_mm_blend_pd
, __m128d
, __m128d
, __m128d
, 1)
136 test_2 (_mm_dp_ps
, __m128
, __m128
, __m128
, 1)
137 test_2 (_mm_dp_pd
, __m128d
, __m128d
, __m128d
, 1)
138 test_2 (_mm_insert_ps
, __m128
, __m128
, __m128
, 1)
139 test_1 (_mm_extract_ps
, int, __m128
, 1)
140 test_2 (_mm_insert_epi8
, __m128i
, __m128i
, int, 1)
141 test_2 (_mm_insert_epi32
, __m128i
, __m128i
, int, 1)
143 test_2 (_mm_insert_epi64
, __m128i
, __m128i
, long long, 1)
145 test_1 (_mm_extract_epi8
, int, __m128i
, 1)
146 test_1 (_mm_extract_epi32
, int, __m128i
, 1)
148 test_1 (_mm_extract_epi64
, long long, __m128i
, 1)
150 test_2 (_mm_mpsadbw_epu8
, __m128i
, __m128i
, __m128i
, 1)
151 test_2 (_mm_cmpistrm
, __m128i
, __m128i
, __m128i
, 1)
152 test_2 (_mm_cmpistri
, int, __m128i
, __m128i
, 1)
153 test_4 (_mm_cmpestrm
, __m128i
, __m128i
, int, __m128i
, int, 1)
154 test_4 (_mm_cmpestri
, int, __m128i
, int, __m128i
, int, 1)
155 test_2 (_mm_cmpistra
, int, __m128i
, __m128i
, 1)
156 test_2 (_mm_cmpistrc
, int, __m128i
, __m128i
, 1)
157 test_2 (_mm_cmpistro
, int, __m128i
, __m128i
, 1)
158 test_2 (_mm_cmpistrs
, int, __m128i
, __m128i
, 1)
159 test_2 (_mm_cmpistrz
, int, __m128i
, __m128i
, 1)
160 test_4 (_mm_cmpestra
, int, __m128i
, int, __m128i
, int, 1)
161 test_4 (_mm_cmpestrc
, int, __m128i
, int, __m128i
, int, 1)
162 test_4 (_mm_cmpestro
, int, __m128i
, int, __m128i
, int, 1)
163 test_4 (_mm_cmpestrs
, int, __m128i
, int, __m128i
, int, 1)
164 test_4 (_mm_cmpestrz
, int, __m128i
, int, __m128i
, int, 1)
166 /* immintrin.h (AVX/AVX2/RDRND/FSGSBASE/F16C/RTM) */
167 #ifdef DIFFERENT_PRAGMAS
168 #pragma GCC target ("avx,avx2,rdrnd,fsgsbase,f16c,rtm")
170 #include <immintrin.h>
171 test_1 (_cvtss_sh
, unsigned short, float, 1)
172 test_1 (_mm_cvtps_ph
, __m128i
, __m128
, 1)
173 test_1 (_mm256_cvtps_ph
, __m128i
, __m256
, 1)
176 test_2 (_mm256_blend_pd
, __m256d
, __m256d
, __m256d
, 1)
177 test_2 (_mm256_blend_ps
, __m256
, __m256
, __m256
, 1)
178 test_2 (_mm256_dp_ps
, __m256
, __m256
, __m256
, 1)
179 test_2 (_mm256_shuffle_pd
, __m256d
, __m256d
, __m256d
, 1)
180 test_2 (_mm256_shuffle_ps
, __m256
, __m256
, __m256
, 1)
181 test_2 (_mm_cmp_sd
, __m128d
, __m128d
, __m128d
, 1)
182 test_2 (_mm_cmp_ss
, __m128
, __m128
, __m128
, 1)
183 test_2 (_mm_cmp_pd
, __m128d
, __m128d
, __m128d
, 1)
184 test_2 (_mm_cmp_ps
, __m128
, __m128
, __m128
, 1)
185 test_2 (_mm256_cmp_pd
, __m256d
, __m256d
, __m256d
, 1)
186 test_2 (_mm256_cmp_ps
, __m256
, __m256
, __m256
, 1)
187 test_1 (_mm256_extractf128_pd
, __m128d
, __m256d
, 1)
188 test_1 (_mm256_extractf128_ps
, __m128
, __m256
, 1)
189 test_1 (_mm256_extractf128_si256
, __m128i
, __m256i
, 1)
190 test_1 (_mm256_extract_epi8
, int, __m256i
, 20)
191 test_1 (_mm256_extract_epi16
, int, __m256i
, 13)
192 test_1 (_mm256_extract_epi32
, int, __m256i
, 6)
194 test_1 (_mm256_extract_epi64
, long long, __m256i
, 2)
196 test_1 (_mm_permute_pd
, __m128d
, __m128d
, 1)
197 test_1 (_mm256_permute_pd
, __m256d
, __m256d
, 1)
198 test_1 (_mm_permute_ps
, __m128
, __m128
, 1)
199 test_1 (_mm256_permute_ps
, __m256
, __m256
, 1)
200 test_2 (_mm256_permute2f128_pd
, __m256d
, __m256d
, __m256d
, 1)
201 test_2 (_mm256_permute2f128_ps
, __m256
, __m256
, __m256
, 1)
202 test_2 (_mm256_permute2f128_si256
, __m256i
, __m256i
, __m256i
, 1)
203 test_2 (_mm256_insertf128_pd
, __m256d
, __m256d
, __m128d
, 1)
204 test_2 (_mm256_insertf128_ps
, __m256
, __m256
, __m128
, 1)
205 test_2 (_mm256_insertf128_si256
, __m256i
, __m256i
, __m128i
, 1)
206 test_2 (_mm256_insert_epi8
, __m256i
, __m256i
, int, 30)
207 test_2 (_mm256_insert_epi16
, __m256i
, __m256i
, int, 7)
208 test_2 (_mm256_insert_epi32
, __m256i
, __m256i
, int, 3)
210 test_2 (_mm256_insert_epi64
, __m256i
, __m256i
, long long, 1)
212 test_1 (_mm256_round_pd
, __m256d
, __m256d
, 1)
213 test_1 (_mm256_round_ps
, __m256
, __m256
, 1)
216 test_2 ( _mm256_mpsadbw_epu8
, __m256i
, __m256i
, __m256i
, 1)
217 test_2 ( _mm256_alignr_epi8
, __m256i
, __m256i
, __m256i
, 1)
218 test_2 ( _mm256_blend_epi16
, __m256i
, __m256i
, __m256i
, 1)
219 test_1 ( _mm256_shuffle_epi32
, __m256i
, __m256i
, 1)
220 test_1 ( _mm256_shufflehi_epi16
, __m256i
, __m256i
, 1)
221 test_1 ( _mm256_shufflelo_epi16
, __m256i
, __m256i
, 1)
222 test_1 ( _mm256_slli_si256
, __m256i
, __m256i
, 8)
223 test_1 ( _mm256_srli_si256
, __m256i
, __m256i
, 8)
224 test_2 ( _mm_blend_epi32
, __m128i
, __m128i
, __m128i
, 1)
225 test_2 ( _mm256_blend_epi32
, __m256i
, __m256i
, __m256
, 1)
226 test_1 ( _mm256_permute4x64_pd
, __m256d
, __m256d
, 1)
227 test_1 ( _mm256_permute4x64_epi64
, __m256i
, __m256i
, 1)
228 test_2 ( _mm256_permute2x128_si256
, __m256i
, __m256i
, __m256i
, 1)
229 test_1 ( _mm256_extracti128_si256
, __m128i
, __m256i
, 1)
230 test_2 ( _mm256_inserti128_si256
, __m256i
, __m256i
, __m128i
, 1)
231 test_2 ( _mm_i32gather_pd
, __m128d
, double const *, __m128i
, 1)
232 test_2 ( _mm256_i32gather_pd
, __m256d
, double const *, __m128i
, 1)
233 test_2 ( _mm_i64gather_pd
, __m128d
, double const *, __m128i
, 1)
234 test_2 ( _mm256_i64gather_pd
, __m256d
, double const *, __m256i
, 1)
235 test_2 ( _mm_i32gather_ps
, __m128
, float const *, __m128i
, 1)
236 test_2 ( _mm256_i32gather_ps
, __m256
, float const *, __m256i
, 1)
237 test_2 ( _mm_i64gather_ps
, __m128
, float const *, __m128i
, 1)
238 test_2 ( _mm256_i64gather_ps
, __m128
, float const *, __m256i
, 1)
239 test_2 ( _mm_i32gather_epi64
, __m128i
, long long int const *, __m128i
, 1)
240 test_2 ( _mm256_i32gather_epi64
, __m256i
, long long int const *, __m128i
, 1)
241 test_2 ( _mm_i64gather_epi64
, __m128i
, long long int const *, __m128i
, 1)
242 test_2 ( _mm256_i64gather_epi64
, __m256i
, long long int const *, __m256i
, 1)
243 test_2 ( _mm_i32gather_epi32
, __m128i
, int const *, __m128i
, 1)
244 test_2 ( _mm256_i32gather_epi32
, __m256i
, int const *, __m256i
, 1)
245 test_2 ( _mm_i64gather_epi32
, __m128i
, int const *, __m128i
, 1)
246 test_2 ( _mm256_i64gather_epi32
, __m128i
, int const *, __m256i
, 1)
249 test_0 ( _xabort
, void, 1)
251 /* wmmintrin.h (AES/PCLMUL). */
252 #ifdef DIFFERENT_PRAGMAS
253 #pragma GCC target ("aes,pclmul")
255 #include <wmmintrin.h>
256 test_1 (_mm_aeskeygenassist_si128
, __m128i
, __m128i
, 1)
257 test_2 (_mm_clmulepi64_si128
, __m128i
, __m128i
, __m128i
, 1)
259 /* popcnintrin.h (POPCNT). */
260 #ifdef DIFFERENT_PRAGMAS
261 #pragma GCC target ("popcnt")
263 #include <popcntintrin.h>
265 /* x86intrin.h (FMA4/XOP/LWP/BMI/BMI2/TBM/LZCNT/FMA). */
266 #ifdef DIFFERENT_PRAGMAS
267 #pragma GCC target ("fma4,xop,lwp,bmi,bmi2,tbm,lzcnt,fma,rdseed,prfchw")
269 #include <x86intrin.h>
271 test_1 ( _mm_roti_epi8
, __m128i
, __m128i
, 1)
272 test_1 ( _mm_roti_epi16
, __m128i
, __m128i
, 1)
273 test_1 ( _mm_roti_epi32
, __m128i
, __m128i
, 1)
274 test_1 ( _mm_roti_epi64
, __m128i
, __m128i
, 1)
275 test_3 (_mm_permute2_pd
, __m128d
, __m128d
, __m128d
, __m128d
, 1)
276 test_3 (_mm256_permute2_pd
, __m256d
, __m256d
, __m256d
, __m256d
, 1)
277 test_3 (_mm_permute2_ps
, __m128
, __m128
, __m128
, __m128
, 1)
278 test_3 (_mm256_permute2_ps
, __m256
, __m256
, __m256
, __m256
, 1)
281 test_2 ( __lwpval32
, void, unsigned int, unsigned int, 1)
282 test_2 ( __lwpins32
, unsigned char, unsigned int, unsigned int, 1)
284 test_2 ( __lwpval64
, void, unsigned long long, unsigned int, 1)
285 test_2 ( __lwpins64
, unsigned char, unsigned long long, unsigned int, 1)
289 test_1 ( __bextri_u32
, unsigned int, unsigned int, 1)
291 test_1 ( __bextri_u64
, unsigned long long, unsigned long long, 1)