PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / avx2-check.h
blob25bed5e0da6ab2c02a51a61509da5371a831b059
1 #include <stdlib.h>
2 #include "cpuid.h"
3 #include "m256-check.h"
4 #include "avx-os-support.h"
6 static void avx2_test (void);
8 static void __attribute__ ((noinline)) do_test (void)
10 avx2_test ();
13 static int
14 check_osxsave (void)
16 unsigned int eax, ebx, ecx, edx;
18 __cpuid (1, eax, ebx, ecx, edx);
19 return (ecx & bit_OSXSAVE) != 0;
22 int
23 main ()
25 unsigned int eax, ebx, ecx, edx;
27 if (!__get_cpuid_count (7, 0, &eax, &ebx, &ecx, &edx))
28 return 0;
30 /* Run AVX2 test only if host has AVX2 support. */
31 if (check_osxsave () && (ebx & bit_AVX2) && avx_os_support ())
33 do_test ();
34 #ifdef DEBUG
35 printf ("PASSED\n");
36 #endif
37 return 0;
40 #ifdef DEBUG
41 printf ("SKIPPED\n");
42 #endif
43 return 0;