2018-05-17 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / avx512-check.h
blob234e60c818b4bb812560741dcd997b470864701e
1 #include <stdlib.h>
2 #include "cpuid.h"
3 #include "m512-check.h"
4 #include "avx512f-os-support.h"
6 #ifndef DO_TEST
7 #define DO_TEST do_test
8 #ifdef AVX512VL
9 static void test_256 (void);
10 static void test_128 (void);
11 #else
12 static void test_512 (void);
13 #endif
15 __attribute__ ((noinline))
16 static void
17 do_test (void)
19 #ifdef AVX512VL
20 test_256 ();
21 test_128 ();
22 #else
23 test_512 ();
24 #endif
26 #endif
28 static int
29 check_osxsave (void)
31 unsigned int eax, ebx, ecx, edx;
33 __cpuid (1, eax, ebx, ecx, edx);
34 return (ecx & bit_OSXSAVE) != 0;
37 int
38 main ()
40 unsigned int eax, ebx, ecx, edx;
42 if (!__get_cpuid_count (7, 0, &eax, &ebx, &ecx, &edx))
43 return 0;
45 /* Run AVX512 test only if host has ISA support. */
46 if (check_osxsave ()
47 && (ebx & bit_AVX512F)
48 #ifdef AVX512VL
49 && (ebx & bit_AVX512VL)
50 #endif
51 #ifdef AVX512ER
52 && (ebx & bit_AVX512ER)
53 #endif
54 #ifdef AVX512CD
55 && (ebx & bit_AVX512CD)
56 #endif
57 #ifdef AVX512DQ
58 && (ebx & bit_AVX512DQ)
59 #endif
60 #ifdef AVX512BW
61 && (ebx & bit_AVX512BW)
62 #endif
63 #ifdef AVX512IFMA
64 && (ebx & bit_AVX512IFMA)
65 #endif
66 #ifdef AVX512VBMI
67 && (ecx & bit_AVX512VBMI)
68 #endif
69 #ifdef AVX5124FMAPS
70 && (edx & bit_AVX5124FMAPS)
71 #endif
72 #ifdef AVX5124VNNIW
73 && (edx & bit_AVX5124VNNIW)
74 #endif
75 #ifdef AVX512VPOPCNTDQ
76 && (ecx & bit_AVX512VPOPCNTDQ)
77 #endif
78 #ifdef AVX512BITALG
79 && (ecx & bit_AVX512BITALG)
80 #endif
81 #ifdef GFNI
82 && (ecx & bit_GFNI)
83 #endif
84 #ifdef AVX512VBMI2
85 && (ecx & bit_AVX512VBMI2)
86 #endif
87 #ifdef AVX512VNNI
88 && (ecx & bit_AVX512VNNI)
89 #endif
90 #ifdef VAES
91 && (ecx & bit_VAES)
92 #endif
93 #ifdef VPCLMULQDQ
94 && (ecx & bit_VPCLMULQDQ)
95 #endif
96 && avx512f_os_support ())
98 DO_TEST ();
99 #ifdef DEBUG
100 printf ("PASSED\n");
101 #endif
102 return 0;
105 #ifdef DEBUG
106 printf ("SKIPPED\n");
107 #endif
108 return 0;