PR target/82353
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / i386.exp
blobeae253192ad6a1ea959c61a3e65a45b09fe1b537
1 # Copyright (C) 1997-2017 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with GCC; see the file COPYING3. If not see
15 # <http://www.gnu.org/licenses/>.
17 # GCC testsuite that uses the `dg.exp' driver.
19 # Exit immediately if this isn't a x86 target.
20 if { ![istarget i?86*-*-*] && ![istarget x86_64-*-*] } then {
21 return
24 # Load support procs.
25 load_lib gcc-dg.exp
26 load_lib clearcap.exp
27 load_lib mpx-dg.exp
29 # Return 1 if attribute ms_hook_prologue is supported.
30 proc check_effective_target_ms_hook_prologue { } {
31 if { [check_no_compiler_messages ms_hook_prologue object {
32 void __attribute__ ((__ms_hook_prologue__)) foo ();
33 } ""] } {
34 return 1
35 } else {
36 return 0
40 # Return 1 if 3dnow instructions can be compiled.
41 proc check_effective_target_3dnow { } {
42 return [check_no_compiler_messages 3dnow object {
43 typedef int __m64 __attribute__ ((__vector_size__ (8)));
44 typedef float __v2sf __attribute__ ((__vector_size__ (8)));
46 __m64 _m_pfadd (__m64 __A, __m64 __B)
48 return (__m64) __builtin_ia32_pfadd ((__v2sf)__A, (__v2sf)__B);
50 } "-O2 -m3dnow" ]
53 # Return 1 if sse3 instructions can be compiled.
54 proc check_effective_target_sse3 { } {
55 return [check_no_compiler_messages sse3 object {
56 typedef double __m128d __attribute__ ((__vector_size__ (16)));
57 typedef double __v2df __attribute__ ((__vector_size__ (16)));
59 __m128d _mm_addsub_pd (__m128d __X, __m128d __Y)
61 return (__m128d) __builtin_ia32_addsubpd ((__v2df)__X, (__v2df)__Y);
63 } "-O2 -msse3" ]
66 # Return 1 if ssse3 instructions can be compiled.
67 proc check_effective_target_ssse3 { } {
68 return [check_no_compiler_messages ssse3 object {
69 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
70 typedef int __v4si __attribute__ ((__vector_size__ (16)));
72 __m128i _mm_abs_epi32 (__m128i __X)
74 return (__m128i) __builtin_ia32_pabsd128 ((__v4si)__X);
76 } "-O2 -mssse3" ]
79 # Return 1 if aes instructions can be compiled.
80 proc check_effective_target_aes { } {
81 return [check_no_compiler_messages aes object {
82 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
83 typedef long long __v2di __attribute__ ((__vector_size__ (16)));
85 __m128i _mm_aesimc_si128 (__m128i __X)
87 return (__m128i) __builtin_ia32_aesimc128 ((__v2di)__X);
89 } "-O2 -maes" ]
92 # Return 1 if vaes instructions can be compiled.
93 proc check_effective_target_vaes { } {
94 return [check_no_compiler_messages vaes object {
95 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
96 typedef long long __v2di __attribute__ ((__vector_size__ (16)));
98 __m128i _mm_aesimc_si128 (__m128i __X)
100 return (__m128i) __builtin_ia32_aesimc128 ((__v2di)__X);
102 } "-O2 -maes -mavx" ]
105 # Return 1 if pclmul instructions can be compiled.
106 proc check_effective_target_pclmul { } {
107 return [check_no_compiler_messages pclmul object {
108 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
109 typedef long long __v2di __attribute__ ((__vector_size__ (16)));
111 __m128i pclmulqdq_test (__m128i __X, __m128i __Y)
113 return (__m128i) __builtin_ia32_pclmulqdq128 ((__v2di)__X,
114 (__v2di)__Y,
117 } "-O2 -mpclmul" ]
120 # Return 1 if vpclmul instructions can be compiled.
121 proc check_effective_target_vpclmul { } {
122 return [check_no_compiler_messages vpclmul object {
123 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
124 typedef long long __v2di __attribute__ ((__vector_size__ (16)));
126 __m128i pclmulqdq_test (__m128i __X, __m128i __Y)
128 return (__m128i) __builtin_ia32_pclmulqdq128 ((__v2di)__X,
129 (__v2di)__Y,
132 } "-O2 -mpclmul -mavx" ]
135 # Return 1 if sse4a instructions can be compiled.
136 proc check_effective_target_sse4a { } {
137 return [check_no_compiler_messages sse4a object {
138 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
139 typedef long long __v2di __attribute__ ((__vector_size__ (16)));
141 __m128i _mm_insert_si64 (__m128i __X,__m128i __Y)
143 return (__m128i) __builtin_ia32_insertq ((__v2di)__X, (__v2di)__Y);
145 } "-O2 -msse4a" ]
148 # Return 1 if fma4 instructions can be compiled.
149 proc check_effective_target_fma4 { } {
150 return [check_no_compiler_messages fma4 object {
151 typedef float __m128 __attribute__ ((__vector_size__ (16)));
152 typedef float __v4sf __attribute__ ((__vector_size__ (16)));
153 __m128 _mm_macc_ps(__m128 __A, __m128 __B, __m128 __C)
155 return (__m128) __builtin_ia32_vfmaddps ((__v4sf)__A,
156 (__v4sf)__B,
157 (__v4sf)__C);
159 } "-O2 -mfma4" ]
162 # Return 1 if fma instructions can be compiled.
163 proc check_effective_target_fma { } {
164 return [check_no_compiler_messages fma object {
165 typedef float __m128 __attribute__ ((__vector_size__ (16)));
166 typedef float __v4sf __attribute__ ((__vector_size__ (16)));
167 __m128 _mm_macc_ps(__m128 __A, __m128 __B, __m128 __C)
169 return (__m128) __builtin_ia32_vfmaddps ((__v4sf)__A,
170 (__v4sf)__B,
171 (__v4sf)__C);
173 } "-O2 -mfma" ]
176 # Return 1 if xop instructions can be compiled.
177 proc check_effective_target_xop { } {
178 return [check_no_compiler_messages xop object {
179 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
180 typedef short __v8hi __attribute__ ((__vector_size__ (16)));
181 __m128i _mm_maccs_epi16(__m128i __A, __m128i __B, __m128i __C)
183 return (__m128i) __builtin_ia32_vpmacssww ((__v8hi)__A,
184 (__v8hi)__B,
185 (__v8hi)__C);
187 } "-O2 -mxop" ]
190 # Return 1 if lzcnt instruction can be compiled.
191 proc check_effective_target_lzcnt { } {
192 return [check_no_compiler_messages lzcnt object {
193 unsigned short _lzcnt (unsigned short __X)
195 return __builtin_clzs (__X);
197 } "-mlzcnt" ]
200 # Return 1 if bmi instructions can be compiled.
201 proc check_effective_target_bmi { } {
202 return [check_no_compiler_messages bmi object {
203 unsigned int __bextr_u32 (unsigned int __X, unsigned int __Y)
205 return __builtin_ia32_bextr_u32 (__X, __Y);
207 } "-mbmi" ]
210 # Return 1 if bmi2 instructions can be compiled.
211 proc check_effective_target_bmi2 { } {
212 return [check_no_compiler_messages bmi2 object {
213 unsigned int
214 _bzhi_u32 (unsigned int __X, unsigned int __Y)
216 return __builtin_ia32_bzhi_si (__X, __Y);
218 } "-mbmi2" ]
221 # Return 1 if ADX instructions can be compiled.
222 proc check_effective_target_adx { } {
223 return [check_no_compiler_messages adx object {
224 unsigned char
225 _adxcarry_u32 (unsigned char __CF, unsigned int __X,
226 unsigned int __Y, unsigned int *__P)
228 return __builtin_ia32_addcarryx_u32 (__CF, __X, __Y, __P);
230 } "-madx" ]
233 # Return 1 if rtm instructions can be compiled.
234 proc check_effective_target_rtm { } {
235 return [check_no_compiler_messages rtm object {
236 void
237 _rtm_xend (void)
239 return __builtin_ia32_xend ();
241 } "-mrtm" ]
244 # Return 1 if avx512f instructions can be compiled.
245 proc check_effective_target_avx512f { } {
246 return [check_no_compiler_messages avx512f object {
247 typedef long long __v8di __attribute__ ((__vector_size__ (64)));
248 __v8di
249 mm512_and_epi64 (__v8di __X, __v8di __Y)
251 return __builtin_ia32_pandq512_mask (__X, __Y, __X, -1);
253 } "-mavx512f" ]
256 # Return 1 if avx512vl instructions can be compiled.
257 proc check_effective_target_avx512vl { } {
258 return [check_no_compiler_messages avx512vl object {
259 typedef long long __v4di __attribute__ ((__vector_size__ (32)));
260 __v4di
261 mm256_and_epi64 (__v4di __X, __v4di __Y)
263 __v4di __W;
264 return __builtin_ia32_pandq256_mask (__X, __Y, __W, -1);
266 } "-mavx512vl" ]
269 # Return 1 if avx512cd instructions can be compiled.
270 proc check_effective_target_avx512cd { } {
271 return [check_no_compiler_messages avx512cd_trans object {
272 typedef long long __v8di __attribute__ ((__vector_size__ (64)));
273 __v8di
274 _mm512_conflict_epi64 (__v8di __W, __v8di __A)
276 return (__v8di) __builtin_ia32_vpconflictdi_512_mask ((__v8di) __A,
277 (__v8di) __W,
278 -1);
280 } "-Wno-psabi -mavx512cd" ]
283 # Return 1 if avx512er instructions can be compiled.
284 proc check_effective_target_avx512er { } {
285 return [check_no_compiler_messages avx512er_trans object {
286 typedef float __v16sf __attribute__ ((__vector_size__ (64)));
287 __v16sf
288 mm512_exp2a23_ps (__v16sf __X)
290 return __builtin_ia32_exp2ps_mask (__X, __X, -1, 4);
292 } "-Wno-psabi -mavx512er" ]
295 # Return 1 if sha instructions can be compiled.
296 proc check_effective_target_sha { } {
297 return [check_no_compiler_messages sha object {
298 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
299 typedef int __v4si __attribute__ ((__vector_size__ (16)));
301 __m128i _mm_sha1msg1_epu32 (__m128i __X, __m128i __Y)
303 return (__m128i) __builtin_ia32_sha1msg1 ((__v4si)__X,
304 (__v4si)__Y);
306 } "-O2 -msha" ]
309 # Return 1 if avx512dq instructions can be compiled.
310 proc check_effective_target_avx512dq { } {
311 return [check_no_compiler_messages avx512dq object {
312 typedef long long __v8di __attribute__ ((__vector_size__ (64)));
313 __v8di
314 _mm512_mask_mullo_epi64 (__v8di __W, __v8di __A, __v8di __B)
316 return (__v8di) __builtin_ia32_pmullq512_mask ((__v8di) __A,
317 (__v8di) __B,
318 (__v8di) __W,
319 -1);
321 } "-mavx512dq" ]
324 # Return 1 if avx512bw instructions can be compiled.
325 proc check_effective_target_avx512bw { } {
326 return [check_no_compiler_messages avx512bw object {
327 typedef short __v32hi __attribute__ ((__vector_size__ (64)));
328 __v32hi
329 _mm512_mask_mulhrs_epi16 (__v32hi __W, __v32hi __A, __v32hi __B)
331 return (__v32hi) __builtin_ia32_pmulhrsw512_mask ((__v32hi) __A,
332 (__v32hi) __B,
333 (__v32hi) __W,
334 -1);
336 } "-mavx512bw" ]
339 # Return 1 if avx512ifma instructions can be compiled.
340 proc check_effective_target_avx512ifma { } {
341 return [check_no_compiler_messages avx512ifma object {
342 typedef long long __v8di __attribute__ ((__vector_size__ (64)));
343 __v8di
344 _mm512_madd52lo_epu64 (__v8di __X, __v8di __Y, __v8di __Z)
346 return (__v8di) __builtin_ia32_vpmadd52luq512_mask ((__v8di) __X,
347 (__v8di) __Y,
348 (__v8di) __Z,
349 -1);
351 } "-mavx512ifma" ]
354 # Return 1 if avx512vbmi instructions can be compiled.
355 proc check_effective_target_avx512vbmi { } {
356 return [check_no_compiler_messages avx512vbmi object {
357 typedef char __v64qi __attribute__ ((__vector_size__ (64)));
358 __v64qi
359 _mm512_multishift_epi64_epi8 (__v64qi __X, __v64qi __Y)
361 return (__v64qi) __builtin_ia32_vpmultishiftqb512_mask ((__v64qi) __X,
362 (__v64qi) __Y,
363 (__v64qi) __Y,
364 -1);
366 } "-mavx512vbmi" ]
369 # Return 1 if avx512_4fmaps instructions can be compiled.
370 proc check_effective_target_avx5124fmaps { } {
371 return [check_no_compiler_messages avx5124fmaps object {
372 typedef float __v16sf __attribute__ ((__vector_size__ (64)));
373 typedef float __v4sf __attribute__ ((__vector_size__ (16)));
375 __v16sf
376 _mm512_mask_4fmadd_ps (__v16sf __DEST, __v16sf __A, __v16sf __B, __v16sf __C,
377 __v16sf __D, __v16sf __E, __v4sf *__F)
379 return (__v16sf) __builtin_ia32_4fmaddps_mask ((__v16sf) __A,
380 (__v16sf) __B,
381 (__v16sf) __C,
382 (__v16sf) __D,
383 (__v16sf) __E,
384 (const __v4sf *) __F,
385 (__v16sf) __DEST,
386 0xffff);
388 } "-mavx5124fmaps" ]
391 # Return 1 if avx512_4vnniw instructions can be compiled.
392 proc check_effective_target_avx5124vnniw { } {
393 return [check_no_compiler_messages avx5124vnniw object {
394 typedef int __v16si __attribute__ ((__vector_size__ (64)));
395 typedef int __v4si __attribute__ ((__vector_size__ (16)));
397 __v16si
398 _mm512_4dpwssd_epi32 (__v16si __A, __v16si __B, __v16si __C,
399 __v16si __D, __v16si __E, __v4si *__F)
401 return (__v16si) __builtin_ia32_vp4dpwssd ((__v16si) __B,
402 (__v16si) __C,
403 (__v16si) __D,
404 (__v16si) __E,
405 (__v16si) __A,
406 (const __v4si *) __F);
408 } "-mavx5124vnniw" ]
411 # Return 1 if avx512_vpopcntdq instructions can be compiled.
412 proc check_effective_target_avx512vpopcntdq { } {
413 return [check_no_compiler_messages avx512vpopcntdq object {
414 typedef int __v16si __attribute__ ((__vector_size__ (64)));
416 __v16si
417 _mm512_popcnt_epi32 (__v16si __A)
419 return (__v16si) __builtin_ia32_vpopcountd_v16si ((__v16si) __A);
421 } "-mavx512vpopcntdq" ]
424 # If a testcase doesn't have special options, use these.
425 global DEFAULT_CFLAGS
426 if ![info exists DEFAULT_CFLAGS] then {
427 set DEFAULT_CFLAGS " -ansi -pedantic-errors"
430 # Initialize `dg'.
431 dg-init
432 clearcap-init
434 global runtests
435 # Special case compilation of vect-args.c so we don't have to
436 # replicate it 16 times.
437 if [runtest_file_p $runtests $srcdir/$subdir/vect-args.c] {
438 foreach type { "" -mmmx -m3dnow -msse -msse2 -mavx -mavx2 -mavx512f } {
439 foreach level { "" -O } {
440 set flags "$type $level"
441 verbose -log "Testing vect-args, $flags" 1
442 dg-test $srcdir/$subdir/vect-args.c $flags ""
447 # Everything else.
448 set tests [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]]
449 set tests [prune $tests $srcdir/$subdir/vect-args.c]
451 # Main loop.
452 dg-runtest $tests "" $DEFAULT_CFLAGS
454 # All done.
455 clearcap-finish
456 dg-finish