Rebase.
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / i386.exp
blobc753a2b6658ac02757814059ffd00a8300be4762
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
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 sse4 instructions can be compiled.
79 proc check_effective_target_sse4 { } {
80 return [check_no_compiler_messages sse4.1 object {
81 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
82 typedef int __v4si __attribute__ ((__vector_size__ (16)));
84 __m128i _mm_mullo_epi32 (__m128i __X, __m128i __Y)
86 return (__m128i) __builtin_ia32_pmulld128 ((__v4si)__X,
87 (__v4si)__Y);
89 } "-O2 -msse4.1" ]
92 # Return 1 if aes instructions can be compiled.
93 proc check_effective_target_aes { } {
94 return [check_no_compiler_messages aes 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" ]
105 # Return 1 if vaes instructions can be compiled.
106 proc check_effective_target_vaes { } {
107 return [check_no_compiler_messages vaes object {
108 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
109 typedef long long __v2di __attribute__ ((__vector_size__ (16)));
111 __m128i _mm_aesimc_si128 (__m128i __X)
113 return (__m128i) __builtin_ia32_aesimc128 ((__v2di)__X);
115 } "-O2 -maes -mavx" ]
118 # Return 1 if pclmul instructions can be compiled.
119 proc check_effective_target_pclmul { } {
120 return [check_no_compiler_messages pclmul object {
121 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
122 typedef long long __v2di __attribute__ ((__vector_size__ (16)));
124 __m128i pclmulqdq_test (__m128i __X, __m128i __Y)
126 return (__m128i) __builtin_ia32_pclmulqdq128 ((__v2di)__X,
127 (__v2di)__Y,
130 } "-O2 -mpclmul" ]
133 # Return 1 if vpclmul instructions can be compiled.
134 proc check_effective_target_vpclmul { } {
135 return [check_no_compiler_messages vpclmul object {
136 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
137 typedef long long __v2di __attribute__ ((__vector_size__ (16)));
139 __m128i pclmulqdq_test (__m128i __X, __m128i __Y)
141 return (__m128i) __builtin_ia32_pclmulqdq128 ((__v2di)__X,
142 (__v2di)__Y,
145 } "-O2 -mpclmul -mavx" ]
148 # Return 1 if sse4a instructions can be compiled.
149 proc check_effective_target_sse4a { } {
150 return [check_no_compiler_messages sse4a object {
151 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
152 typedef long long __v2di __attribute__ ((__vector_size__ (16)));
154 __m128i _mm_insert_si64 (__m128i __X,__m128i __Y)
156 return (__m128i) __builtin_ia32_insertq ((__v2di)__X, (__v2di)__Y);
158 } "-O2 -msse4a" ]
161 # Return 1 if fma4 instructions can be compiled.
162 proc check_effective_target_fma4 { } {
163 return [check_no_compiler_messages fma4 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 -mfma4" ]
175 # Return 1 if fma instructions can be compiled.
176 proc check_effective_target_fma { } {
177 return [check_no_compiler_messages fma object {
178 typedef float __m128 __attribute__ ((__vector_size__ (16)));
179 typedef float __v4sf __attribute__ ((__vector_size__ (16)));
180 __m128 _mm_macc_ps(__m128 __A, __m128 __B, __m128 __C)
182 return (__m128) __builtin_ia32_vfmaddps ((__v4sf)__A,
183 (__v4sf)__B,
184 (__v4sf)__C);
186 } "-O2 -mfma" ]
189 # Return 1 if xop instructions can be compiled.
190 proc check_effective_target_xop { } {
191 return [check_no_compiler_messages xop object {
192 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
193 typedef short __v8hi __attribute__ ((__vector_size__ (16)));
194 __m128i _mm_maccs_epi16(__m128i __A, __m128i __B, __m128i __C)
196 return (__m128i) __builtin_ia32_vpmacssww ((__v8hi)__A,
197 (__v8hi)__B,
198 (__v8hi)__C);
200 } "-O2 -mxop" ]
203 # Return 1 if lzcnt instruction can be compiled.
204 proc check_effective_target_lzcnt { } {
205 return [check_no_compiler_messages lzcnt object {
206 unsigned short _lzcnt (unsigned short __X)
208 return __builtin_clzs (__X);
210 } "-mlzcnt" ]
213 # Return 1 if bmi instructions can be compiled.
214 proc check_effective_target_bmi { } {
215 return [check_no_compiler_messages bmi object {
216 unsigned int __bextr_u32 (unsigned int __X, unsigned int __Y)
218 return __builtin_ia32_bextr_u32 (__X, __Y);
220 } "-mbmi" ]
223 # Return 1 if bmi2 instructions can be compiled.
224 proc check_effective_target_bmi2 { } {
225 return [check_no_compiler_messages bmi2 object {
226 unsigned int
227 _bzhi_u32 (unsigned int __X, unsigned int __Y)
229 return __builtin_ia32_bzhi_si (__X, __Y);
231 } "-mbmi2" ]
234 # Return 1 if ADX instructions can be compiled.
235 proc check_effective_target_adx { } {
236 return [check_no_compiler_messages adx object {
237 unsigned char
238 _adxcarry_u32 (unsigned char __CF, unsigned int __X,
239 unsigned int __Y, unsigned int *__P)
241 return __builtin_ia32_addcarryx_u32 (__CF, __X, __Y, __P);
243 } "-madx" ]
246 # Return 1 if rtm instructions can be compiled.
247 proc check_effective_target_rtm { } {
248 return [check_no_compiler_messages rtm object {
249 void
250 _rtm_xend (void)
252 return __builtin_ia32_xend ();
254 } "-mrtm" ]
257 # Return 1 if avx512f instructions can be compiled.
258 proc check_effective_target_avx512f { } {
259 return [check_no_compiler_messages avx512f object {
260 typedef long long __v8di __attribute__ ((__vector_size__ (64)));
261 __v8di
262 mm512_and_epi64 (__v8di __X, __v8di __Y)
264 return __builtin_ia32_pandq512_mask (__X, __Y, __X, -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 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 # If a testcase doesn't have special options, use these.
310 global DEFAULT_CFLAGS
311 if ![info exists DEFAULT_CFLAGS] then {
312 set DEFAULT_CFLAGS " -ansi -pedantic-errors"
315 # Initialize `dg'.
316 dg-init
317 clearcap-init
319 # Special case compilation of vect-args.c so we don't have to
320 # replicate it 10 times.
321 foreach type { "" -mmmx -m3dnow -msse -msse2 } {
322 foreach level { "" -O } {
323 set flags "$type $level"
324 verbose -log "Testing vect-args, $flags" 1
325 dg-test $srcdir/$subdir/vect-args.c $flags ""
329 # Everything else.
330 set tests [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]]
331 set tests [prune $tests $srcdir/$subdir/vect-args.c]
333 # Main loop.
334 dg-runtest $tests "" $DEFAULT_CFLAGS
336 # All done.
337 clearcap-finish
338 dg-finish