* g++.dg/other/i386-2.C (dg-options): Add -mavx512pf.
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / i386.exp
blob080e302b782d35e1a3f4425b95cac8357daa5a64
1 # Copyright (C) 1997-2014 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
27 # Return 1 if attribute ms_hook_prologue is supported.
28 proc check_effective_target_ms_hook_prologue { } {
29 if { [check_no_compiler_messages ms_hook_prologue object {
30 void __attribute__ ((__ms_hook_prologue__)) foo ();
31 } ""] } {
32 return 1
33 } else {
34 return 0
38 # Return 1 if 3dnow instructions can be compiled.
39 proc check_effective_target_3dnow { } {
40 return [check_no_compiler_messages 3dnow object {
41 typedef int __m64 __attribute__ ((__vector_size__ (8)));
42 typedef float __v2sf __attribute__ ((__vector_size__ (8)));
44 __m64 _m_pfadd (__m64 __A, __m64 __B)
46 return (__m64) __builtin_ia32_pfadd ((__v2sf)__A, (__v2sf)__B);
48 } "-O2 -m3dnow" ]
51 # Return 1 if sse3 instructions can be compiled.
52 proc check_effective_target_sse3 { } {
53 return [check_no_compiler_messages sse3 object {
54 typedef double __m128d __attribute__ ((__vector_size__ (16)));
55 typedef double __v2df __attribute__ ((__vector_size__ (16)));
57 __m128d _mm_addsub_pd (__m128d __X, __m128d __Y)
59 return (__m128d) __builtin_ia32_addsubpd ((__v2df)__X, (__v2df)__Y);
61 } "-O2 -msse3" ]
64 # Return 1 if ssse3 instructions can be compiled.
65 proc check_effective_target_ssse3 { } {
66 return [check_no_compiler_messages ssse3 object {
67 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
68 typedef int __v4si __attribute__ ((__vector_size__ (16)));
70 __m128i _mm_abs_epi32 (__m128i __X)
72 return (__m128i) __builtin_ia32_pabsd128 ((__v4si)__X);
74 } "-O2 -mssse3" ]
77 # Return 1 if sse4 instructions can be compiled.
78 proc check_effective_target_sse4 { } {
79 return [check_no_compiler_messages sse4.1 object {
80 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
81 typedef int __v4si __attribute__ ((__vector_size__ (16)));
83 __m128i _mm_mullo_epi32 (__m128i __X, __m128i __Y)
85 return (__m128i) __builtin_ia32_pmulld128 ((__v4si)__X,
86 (__v4si)__Y);
88 } "-O2 -msse4.1" ]
91 # Return 1 if aes instructions can be compiled.
92 proc check_effective_target_aes { } {
93 return [check_no_compiler_messages aes 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" ]
104 # Return 1 if vaes instructions can be compiled.
105 proc check_effective_target_vaes { } {
106 return [check_no_compiler_messages vaes object {
107 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
108 typedef long long __v2di __attribute__ ((__vector_size__ (16)));
110 __m128i _mm_aesimc_si128 (__m128i __X)
112 return (__m128i) __builtin_ia32_aesimc128 ((__v2di)__X);
114 } "-O2 -maes -mavx" ]
117 # Return 1 if pclmul instructions can be compiled.
118 proc check_effective_target_pclmul { } {
119 return [check_no_compiler_messages pclmul object {
120 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
121 typedef long long __v2di __attribute__ ((__vector_size__ (16)));
123 __m128i pclmulqdq_test (__m128i __X, __m128i __Y)
125 return (__m128i) __builtin_ia32_pclmulqdq128 ((__v2di)__X,
126 (__v2di)__Y,
129 } "-O2 -mpclmul" ]
132 # Return 1 if vpclmul instructions can be compiled.
133 proc check_effective_target_vpclmul { } {
134 return [check_no_compiler_messages vpclmul object {
135 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
136 typedef long long __v2di __attribute__ ((__vector_size__ (16)));
138 __m128i pclmulqdq_test (__m128i __X, __m128i __Y)
140 return (__m128i) __builtin_ia32_pclmulqdq128 ((__v2di)__X,
141 (__v2di)__Y,
144 } "-O2 -mpclmul -mavx" ]
147 # Return 1 if sse4a instructions can be compiled.
148 proc check_effective_target_sse4a { } {
149 return [check_no_compiler_messages sse4a object {
150 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
151 typedef long long __v2di __attribute__ ((__vector_size__ (16)));
153 __m128i _mm_insert_si64 (__m128i __X,__m128i __Y)
155 return (__m128i) __builtin_ia32_insertq ((__v2di)__X, (__v2di)__Y);
157 } "-O2 -msse4a" ]
160 # Return 1 if fma4 instructions can be compiled.
161 proc check_effective_target_fma4 { } {
162 return [check_no_compiler_messages fma4 object {
163 typedef float __m128 __attribute__ ((__vector_size__ (16)));
164 typedef float __v4sf __attribute__ ((__vector_size__ (16)));
165 __m128 _mm_macc_ps(__m128 __A, __m128 __B, __m128 __C)
167 return (__m128) __builtin_ia32_vfmaddps ((__v4sf)__A,
168 (__v4sf)__B,
169 (__v4sf)__C);
171 } "-O2 -mfma4" ]
174 # Return 1 if fma instructions can be compiled.
175 proc check_effective_target_fma { } {
176 return [check_no_compiler_messages fma object {
177 typedef float __m128 __attribute__ ((__vector_size__ (16)));
178 typedef float __v4sf __attribute__ ((__vector_size__ (16)));
179 __m128 _mm_macc_ps(__m128 __A, __m128 __B, __m128 __C)
181 return (__m128) __builtin_ia32_vfmaddps ((__v4sf)__A,
182 (__v4sf)__B,
183 (__v4sf)__C);
185 } "-O2 -mfma" ]
188 # Return 1 if xop instructions can be compiled.
189 proc check_effective_target_xop { } {
190 return [check_no_compiler_messages xop object {
191 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
192 typedef short __v8hi __attribute__ ((__vector_size__ (16)));
193 __m128i _mm_maccs_epi16(__m128i __A, __m128i __B, __m128i __C)
195 return (__m128i) __builtin_ia32_vpmacssww ((__v8hi)__A,
196 (__v8hi)__B,
197 (__v8hi)__C);
199 } "-O2 -mxop" ]
202 # Return 1 if lzcnt instruction can be compiled.
203 proc check_effective_target_lzcnt { } {
204 return [check_no_compiler_messages lzcnt object {
205 unsigned short _lzcnt (unsigned short __X)
207 return __builtin_clzs (__X);
209 } "-mlzcnt" ]
212 # Return 1 if bmi instructions can be compiled.
213 proc check_effective_target_bmi { } {
214 return [check_no_compiler_messages bmi object {
215 unsigned int __bextr_u32 (unsigned int __X, unsigned int __Y)
217 return __builtin_ia32_bextr_u32 (__X, __Y);
219 } "-mbmi" ]
222 # Return 1 if bmi2 instructions can be compiled.
223 proc check_effective_target_bmi2 { } {
224 return [check_no_compiler_messages bmi2 object {
225 unsigned int
226 _bzhi_u32 (unsigned int __X, unsigned int __Y)
228 return __builtin_ia32_bzhi_si (__X, __Y);
230 } "-mbmi2" ]
233 # Return 1 if ADX instructions can be compiled.
234 proc check_effective_target_adx { } {
235 return [check_no_compiler_messages adx object {
236 unsigned char
237 _adxcarry_u32 (unsigned char __CF, unsigned int __X,
238 unsigned int __Y, unsigned int *__P)
240 return __builtin_ia32_addcarryx_u32 (__CF, __X, __Y, __P);
242 } "-madx" ]
245 # Return 1 if rtm instructions can be compiled.
246 proc check_effective_target_rtm { } {
247 return [check_no_compiler_messages rtm object {
248 void
249 _rtm_xend (void)
251 return __builtin_ia32_xend ();
253 } "-mrtm" ]
256 # Return 1 if avx512f instructions can be compiled.
257 proc check_effective_target_avx512f { } {
258 return [check_no_compiler_messages avx512f object {
259 typedef long long __v8di __attribute__ ((__vector_size__ (64)));
260 __v8di
261 mm512_and_epi64 (__v8di __X, __v8di __Y)
263 __v8di __W;
264 return __builtin_ia32_pandq512_mask (__X, __Y, __W, -1);
266 } "-mavx512f" ]
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 __v16sf __W;
291 return __builtin_ia32_exp2ps_mask (__X, __W, -1, 4);
293 } "-Wno-psabi -mavx512er" ]
296 # Return 1 if sha instructions can be compiled.
297 proc check_effective_target_sha { } {
298 return [check_no_compiler_messages sha object {
299 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
300 typedef int __v4si __attribute__ ((__vector_size__ (16)));
302 __m128i _mm_sha1msg1_epu32 (__m128i __X, __m128i __Y)
304 return (__m128i) __builtin_ia32_sha1msg1 ((__v4si)__X,
305 (__v4si)__Y);
307 } "-O2 -msha" ]
310 # If the linker used understands -M <mapfile>, pass it to clear hardware
311 # capabilities set by the Sun assembler.
312 # Try mapfile syntax v2 first which is the only way to clear hwcap_2 flags.
313 set clearcap_ldflags "-Wl,-M,$srcdir/$subdir/clearcapv2.map"
315 if ![check_no_compiler_messages mapfilev2 executable {
316 int main (void) { return 0; }
317 } $clearcap_ldflags ] {
318 # If this doesn't work, fall back to the less capable v1 syntax.
319 set clearcap_ldflags "-Wl,-M,$srcdir/$subdir/clearcap.map"
321 if ![check_no_compiler_messages mapfile executable {
322 int main (void) { return 0; }
323 } $clearcap_ldflags ] {
324 unset clearcap_ldflags
328 if [info exists clearcap_ldflags] {
329 if { [info procs gcc_target_compile] != [list] \
330 && [info procs saved_gcc_target_compile] == [list] } {
331 rename gcc_target_compile saved_gcc_target_compile
333 proc gcc_target_compile { source dest type options } {
334 global clearcap_ldflags
335 # Always pass -Wl,-M,<mapfile>, but don't let it show up in gcc.sum.
336 lappend options "additional_flags=$clearcap_ldflags"
338 return [saved_gcc_target_compile $source $dest $type $options]
343 # If a testcase doesn't have special options, use these.
344 global DEFAULT_CFLAGS
345 if ![info exists DEFAULT_CFLAGS] then {
346 set DEFAULT_CFLAGS " -ansi -pedantic-errors"
349 # Initialize `dg'.
350 dg-init
352 # Special case compilation of vect-args.c so we don't have to
353 # replicate it 10 times.
354 foreach type { "" -mmmx -m3dnow -msse -msse2 } {
355 foreach level { "" -O } {
356 set flags "$type $level"
357 verbose -log "Testing vect-args, $flags" 1
358 dg-test $srcdir/$subdir/vect-args.c $flags ""
362 # Everything else.
363 set tests [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]]
364 set tests [prune $tests $srcdir/$subdir/vect-args.c]
366 # Main loop.
367 dg-runtest $tests "" $DEFAULT_CFLAGS
369 # All done.
370 dg-finish