Remove MPX
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / i386.exp
blob91fa2a61af2d675661803639bf08b681eedf7ceb
1 # Copyright (C) 1997-2018 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
28 # Return 1 if attribute ms_hook_prologue is supported.
29 proc check_effective_target_ms_hook_prologue { } {
30 if { [check_no_compiler_messages ms_hook_prologue object {
31 void __attribute__ ((__ms_hook_prologue__)) foo ();
32 } ""] } {
33 return 1
34 } else {
35 return 0
39 # Return 1 if 3dnow instructions can be compiled.
40 proc check_effective_target_3dnow { } {
41 return [check_no_compiler_messages 3dnow object {
42 typedef int __m64 __attribute__ ((__vector_size__ (8)));
43 typedef float __v2sf __attribute__ ((__vector_size__ (8)));
45 __m64 _m_pfadd (__m64 __A, __m64 __B)
47 return (__m64) __builtin_ia32_pfadd ((__v2sf)__A, (__v2sf)__B);
49 } "-O2 -m3dnow" ]
52 # Return 1 if sse3 instructions can be compiled.
53 proc check_effective_target_sse3 { } {
54 return [check_no_compiler_messages sse3 object {
55 typedef double __m128d __attribute__ ((__vector_size__ (16)));
56 typedef double __v2df __attribute__ ((__vector_size__ (16)));
58 __m128d _mm_addsub_pd (__m128d __X, __m128d __Y)
60 return (__m128d) __builtin_ia32_addsubpd ((__v2df)__X, (__v2df)__Y);
62 } "-O2 -msse3" ]
65 # Return 1 if ssse3 instructions can be compiled.
66 proc check_effective_target_ssse3 { } {
67 return [check_no_compiler_messages ssse3 object {
68 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
69 typedef int __v4si __attribute__ ((__vector_size__ (16)));
71 __m128i _mm_abs_epi32 (__m128i __X)
73 return (__m128i) __builtin_ia32_pabsd128 ((__v4si)__X);
75 } "-O2 -mssse3" ]
78 # Return 1 if aes instructions can be compiled.
79 proc check_effective_target_aes { } {
80 return [check_no_compiler_messages aes object {
81 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
82 typedef long long __v2di __attribute__ ((__vector_size__ (16)));
84 __m128i _mm_aesimc_si128 (__m128i __X)
86 return (__m128i) __builtin_ia32_aesimc128 ((__v2di)__X);
88 } "-O2 -maes" ]
91 # Return 1 if vaes instructions can be compiled.
92 proc check_effective_target_vaes { } {
93 return [check_no_compiler_messages vaes object {
94 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
95 typedef long long __v2di __attribute__ ((__vector_size__ (16)));
97 __m128i _mm_aesimc_si128 (__m128i __X)
99 return (__m128i) __builtin_ia32_aesimc128 ((__v2di)__X);
101 } "-O2 -maes -mavx" ]
104 # Return 1 if pclmul instructions can be compiled.
105 proc check_effective_target_pclmul { } {
106 return [check_no_compiler_messages pclmul object {
107 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
108 typedef long long __v2di __attribute__ ((__vector_size__ (16)));
110 __m128i pclmulqdq_test (__m128i __X, __m128i __Y)
112 return (__m128i) __builtin_ia32_pclmulqdq128 ((__v2di)__X,
113 (__v2di)__Y,
116 } "-O2 -mpclmul" ]
119 # Return 1 if vpclmul instructions can be compiled.
120 proc check_effective_target_vpclmul { } {
121 return [check_no_compiler_messages vpclmul object {
122 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
123 typedef long long __v2di __attribute__ ((__vector_size__ (16)));
125 __m128i pclmulqdq_test (__m128i __X, __m128i __Y)
127 return (__m128i) __builtin_ia32_pclmulqdq128 ((__v2di)__X,
128 (__v2di)__Y,
131 } "-O2 -mpclmul -mavx" ]
134 # Return 1 if sse4a instructions can be compiled.
135 proc check_effective_target_sse4a { } {
136 return [check_no_compiler_messages sse4a object {
137 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
138 typedef long long __v2di __attribute__ ((__vector_size__ (16)));
140 __m128i _mm_insert_si64 (__m128i __X,__m128i __Y)
142 return (__m128i) __builtin_ia32_insertq ((__v2di)__X, (__v2di)__Y);
144 } "-O2 -msse4a" ]
147 # Return 1 if fma4 instructions can be compiled.
148 proc check_effective_target_fma4 { } {
149 return [check_no_compiler_messages fma4 object {
150 typedef float __m128 __attribute__ ((__vector_size__ (16)));
151 typedef float __v4sf __attribute__ ((__vector_size__ (16)));
152 __m128 _mm_macc_ps(__m128 __A, __m128 __B, __m128 __C)
154 return (__m128) __builtin_ia32_vfmaddps ((__v4sf)__A,
155 (__v4sf)__B,
156 (__v4sf)__C);
158 } "-O2 -mfma4" ]
161 # Return 1 if fma instructions can be compiled.
162 proc check_effective_target_fma { } {
163 return [check_no_compiler_messages fma object {
164 typedef float __m128 __attribute__ ((__vector_size__ (16)));
165 typedef float __v4sf __attribute__ ((__vector_size__ (16)));
166 __m128 _mm_macc_ps(__m128 __A, __m128 __B, __m128 __C)
168 return (__m128) __builtin_ia32_vfmaddps ((__v4sf)__A,
169 (__v4sf)__B,
170 (__v4sf)__C);
172 } "-O2 -mfma" ]
175 # Return 1 if xop instructions can be compiled.
176 proc check_effective_target_xop { } {
177 return [check_no_compiler_messages xop object {
178 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
179 typedef short __v8hi __attribute__ ((__vector_size__ (16)));
180 __m128i _mm_maccs_epi16(__m128i __A, __m128i __B, __m128i __C)
182 return (__m128i) __builtin_ia32_vpmacssww ((__v8hi)__A,
183 (__v8hi)__B,
184 (__v8hi)__C);
186 } "-O2 -mxop" ]
189 # Return 1 if lzcnt instruction can be compiled.
190 proc check_effective_target_lzcnt { } {
191 return [check_no_compiler_messages lzcnt object {
192 unsigned short _lzcnt (unsigned short __X)
194 return __builtin_clzs (__X);
196 } "-mlzcnt" ]
199 # Return 1 if bmi instructions can be compiled.
200 proc check_effective_target_bmi { } {
201 return [check_no_compiler_messages bmi object {
202 unsigned int __bextr_u32 (unsigned int __X, unsigned int __Y)
204 return __builtin_ia32_bextr_u32 (__X, __Y);
206 } "-mbmi" ]
209 # Return 1 if ADX instructions can be compiled.
210 proc check_effective_target_adx { } {
211 return [check_no_compiler_messages adx object {
212 unsigned char
213 _adxcarry_u32 (unsigned char __CF, unsigned int __X,
214 unsigned int __Y, unsigned int *__P)
216 return __builtin_ia32_addcarryx_u32 (__CF, __X, __Y, __P);
218 } "-madx" ]
221 # Return 1 if rtm instructions can be compiled.
222 proc check_effective_target_rtm { } {
223 return [check_no_compiler_messages rtm object {
224 void
225 _rtm_xend (void)
227 return __builtin_ia32_xend ();
229 } "-mrtm" ]
232 # Return 1 if avx512vl instructions can be compiled.
233 proc check_effective_target_avx512vl { } {
234 return [check_no_compiler_messages avx512vl object {
235 typedef long long __v4di __attribute__ ((__vector_size__ (32)));
236 __v4di
237 mm256_and_epi64 (__v4di __X, __v4di __Y)
239 __v4di __W;
240 return __builtin_ia32_pandq256_mask (__X, __Y, __W, -1);
242 } "-mavx512vl" ]
245 # Return 1 if avx512cd instructions can be compiled.
246 proc check_effective_target_avx512cd { } {
247 return [check_no_compiler_messages avx512cd_trans object {
248 typedef long long __v8di __attribute__ ((__vector_size__ (64)));
249 __v8di
250 _mm512_conflict_epi64 (__v8di __W, __v8di __A)
252 return (__v8di) __builtin_ia32_vpconflictdi_512_mask ((__v8di) __A,
253 (__v8di) __W,
254 -1);
256 } "-Wno-psabi -mavx512cd" ]
259 # Return 1 if avx512er instructions can be compiled.
260 proc check_effective_target_avx512er { } {
261 return [check_no_compiler_messages avx512er_trans object {
262 typedef float __v16sf __attribute__ ((__vector_size__ (64)));
263 __v16sf
264 mm512_exp2a23_ps (__v16sf __X)
266 return __builtin_ia32_exp2ps_mask (__X, __X, -1, 4);
268 } "-Wno-psabi -mavx512er" ]
271 # Return 1 if sha instructions can be compiled.
272 proc check_effective_target_sha { } {
273 return [check_no_compiler_messages sha object {
274 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
275 typedef int __v4si __attribute__ ((__vector_size__ (16)));
277 __m128i _mm_sha1msg1_epu32 (__m128i __X, __m128i __Y)
279 return (__m128i) __builtin_ia32_sha1msg1 ((__v4si)__X,
280 (__v4si)__Y);
282 } "-O2 -msha" ]
285 # Return 1 if avx512dq instructions can be compiled.
286 proc check_effective_target_avx512dq { } {
287 return [check_no_compiler_messages avx512dq object {
288 typedef long long __v8di __attribute__ ((__vector_size__ (64)));
289 __v8di
290 _mm512_mask_mullo_epi64 (__v8di __W, __v8di __A, __v8di __B)
292 return (__v8di) __builtin_ia32_pmullq512_mask ((__v8di) __A,
293 (__v8di) __B,
294 (__v8di) __W,
295 -1);
297 } "-mavx512dq" ]
300 # Return 1 if avx512bw instructions can be compiled.
301 proc check_effective_target_avx512bw { } {
302 return [check_no_compiler_messages avx512bw object {
303 typedef short __v32hi __attribute__ ((__vector_size__ (64)));
304 __v32hi
305 _mm512_mask_mulhrs_epi16 (__v32hi __W, __v32hi __A, __v32hi __B)
307 return (__v32hi) __builtin_ia32_pmulhrsw512_mask ((__v32hi) __A,
308 (__v32hi) __B,
309 (__v32hi) __W,
310 -1);
312 } "-mavx512bw" ]
315 # Return 1 if avx512ifma instructions can be compiled.
316 proc check_effective_target_avx512ifma { } {
317 return [check_no_compiler_messages avx512ifma object {
318 typedef long long __v8di __attribute__ ((__vector_size__ (64)));
319 __v8di
320 _mm512_madd52lo_epu64 (__v8di __X, __v8di __Y, __v8di __Z)
322 return (__v8di) __builtin_ia32_vpmadd52luq512_mask ((__v8di) __X,
323 (__v8di) __Y,
324 (__v8di) __Z,
325 -1);
327 } "-mavx512ifma" ]
330 # Return 1 if avx512vbmi instructions can be compiled.
331 proc check_effective_target_avx512vbmi { } {
332 return [check_no_compiler_messages avx512vbmi object {
333 typedef char __v64qi __attribute__ ((__vector_size__ (64)));
334 __v64qi
335 _mm512_multishift_epi64_epi8 (__v64qi __X, __v64qi __Y)
337 return (__v64qi) __builtin_ia32_vpmultishiftqb512_mask ((__v64qi) __X,
338 (__v64qi) __Y,
339 (__v64qi) __Y,
340 -1);
342 } "-mavx512vbmi" ]
345 # Return 1 if avx512_4fmaps instructions can be compiled.
346 proc check_effective_target_avx5124fmaps { } {
347 return [check_no_compiler_messages avx5124fmaps object {
348 typedef float __v16sf __attribute__ ((__vector_size__ (64)));
349 typedef float __v4sf __attribute__ ((__vector_size__ (16)));
351 __v16sf
352 _mm512_mask_4fmadd_ps (__v16sf __DEST, __v16sf __A, __v16sf __B, __v16sf __C,
353 __v16sf __D, __v16sf __E, __v4sf *__F)
355 return (__v16sf) __builtin_ia32_4fmaddps_mask ((__v16sf) __A,
356 (__v16sf) __B,
357 (__v16sf) __C,
358 (__v16sf) __D,
359 (__v16sf) __E,
360 (const __v4sf *) __F,
361 (__v16sf) __DEST,
362 0xffff);
364 } "-mavx5124fmaps" ]
367 # Return 1 if avx512_4vnniw instructions can be compiled.
368 proc check_effective_target_avx5124vnniw { } {
369 return [check_no_compiler_messages avx5124vnniw object {
370 typedef int __v16si __attribute__ ((__vector_size__ (64)));
371 typedef int __v4si __attribute__ ((__vector_size__ (16)));
373 __v16si
374 _mm512_4dpwssd_epi32 (__v16si __A, __v16si __B, __v16si __C,
375 __v16si __D, __v16si __E, __v4si *__F)
377 return (__v16si) __builtin_ia32_vp4dpwssd ((__v16si) __B,
378 (__v16si) __C,
379 (__v16si) __D,
380 (__v16si) __E,
381 (__v16si) __A,
382 (const __v4si *) __F);
384 } "-mavx5124vnniw" ]
387 # Return 1 if avx512_vpopcntdq instructions can be compiled.
388 proc check_effective_target_avx512vpopcntdq { } {
389 return [check_no_compiler_messages avx512vpopcntdq object {
390 typedef int __v16si __attribute__ ((__vector_size__ (64)));
392 __v16si
393 _mm512_popcnt_epi32 (__v16si __A)
395 return (__v16si) __builtin_ia32_vpopcountd_v16si ((__v16si) __A);
397 } "-mavx512vpopcntdq" ]
400 # Return 1 if 128 or 256-bit avx512_vpopcntdq instructions can be compiled.
401 proc check_effective_target_avx512vpopcntdqvl { } {
402 return [check_no_compiler_messages avx512vpopcntdqvl object {
403 typedef int __v8si __attribute__ ((__vector_size__ (32)));
405 __v8si
406 _mm256_popcnt_epi32 (__v8si __A)
408 return (__v8si) __builtin_ia32_vpopcountd_v8si ((__v8si) __A);
410 } "-mavx512vpopcntdq -mavx512vl" ]
413 # Return 1 if gfni instructions can be compiled.
414 proc check_effective_target_gfni { } {
415 return [check_no_compiler_messages gfni object {
416 typedef char __v16qi __attribute__ ((__vector_size__ (16)));
418 __v16qi
419 _mm_gf2p8affineinv_epi64_epi8 (__v16qi __A, __v16qi __B, const int __C)
421 return (__v16qi) __builtin_ia32_vgf2p8affineinvqb_v16qi ((__v16qi) __A,
422 (__v16qi) __B,
425 } "-mgfni" ]
428 # Return 1 if avx512vbmi2 instructions can be compiled.
429 proc check_effective_target_avx512vbmi2 { } {
430 return [check_no_compiler_messages avx512vbmi2 object {
431 typedef char __v16qi __attribute__ ((__vector_size__ (16)));
432 typedef unsigned long long __mmask16;
434 __v16qi
435 _mm_mask_compress_epi8 (__v16qi __A, __mmask16 __B, __v16qi __C)
437 return (__v16qi) __builtin_ia32_compressqi128_mask((__v16qi)__C,
438 (__v16qi)__A,
439 (__mmask16)__B);
441 } "-mavx512vbmi2 -mavx512vl" ]
444 # Return 1 if avx512vbmi2 instructions can be compiled.
445 proc check_effective_target_avx512vnni { } {
446 return [check_no_compiler_messages avx512vnni object {
447 typedef int __v16si __attribute__ ((__vector_size__ (64)));
449 __v16si
450 _mm_mask_compress_epi8 (__v16si __A, __v16si __B, __v16si __C)
452 return (__v16si) __builtin_ia32_vpdpbusd_v16si ((__v16si)__A,
453 (__v16si)__B,
454 (__v16si)__C);
456 } "-mavx512vnni -mavx512f" ]
459 # Return 1 if vaes instructions can be compiled.
460 proc check_effective_target_avx512vaes { } {
461 return [check_no_compiler_messages avx512vaes object {
463 typedef int __v16si __attribute__ ((__vector_size__ (64)));
465 __v32qi
466 _mm256_aesdec_epi128 (__v32qi __A, __v32qi __B)
468 return (__v32qi)__builtin_ia32_vaesdec_v32qi ((__v32qi) __A, (__v32qi) __B);
470 } "-mvaes" ]
473 # Return 1 if vpclmulqdq instructions can be compiled.
474 proc check_effective_target_vpclmulqdq { } {
475 return [check_no_compiler_messages vpclmulqdq object {
476 typedef long long __v4di __attribute__ ((__vector_size__ (32)));
478 __v4di
479 _mm256_clmulepi64_epi128 (__v4di __A, __v4di __B)
481 return (__v4di) __builtin_ia32_vpclmulqdq_v4di (__A, __B, 0);
483 } "-mvpclmulqdq -mavx512vl" ]
486 # Return 1 if avx512_bitalg instructions can be compiled.
487 proc check_effective_target_avx512bitalg { } {
488 return [check_no_compiler_messages avx512bitalg object {
489 typedef short int __v32hi __attribute__ ((__vector_size__ (64)));
491 __v32hi
492 _mm512_popcnt_epi16 (__v32hi __A)
494 return (__v32hi) __builtin_ia32_vpopcountw_v32hi ((__v32hi) __A);
496 } "-mavx512bitalg" ]
499 # If a testcase doesn't have special options, use these.
500 global DEFAULT_CFLAGS
501 if ![info exists DEFAULT_CFLAGS] then {
502 set DEFAULT_CFLAGS " -ansi -pedantic-errors"
505 # Initialize `dg'.
506 dg-init
507 clearcap-init
509 global runtests
510 # Special case compilation of vect-args.c so we don't have to
511 # replicate it 16 times.
512 if [runtest_file_p $runtests $srcdir/$subdir/vect-args.c] {
513 foreach type { "" -mmmx -m3dnow -msse -msse2 -mavx -mavx2 -mavx512f } {
514 foreach level { "" -O } {
515 set flags "$type $level"
516 verbose -log "Testing vect-args, $flags" 1
517 dg-test $srcdir/$subdir/vect-args.c $flags ""
522 # Everything else.
523 set tests [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]]
524 set tests [prune $tests $srcdir/$subdir/vect-args.c]
526 # Main loop.
527 dg-runtest $tests "" $DEFAULT_CFLAGS
529 # All done.
530 clearcap-finish
531 dg-finish