Fix gcc.dg/vect/bb-slp-77.c for x86
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / m512-check.h
blobf22dda2113f5fb4b5860a1c3b18e10b4220b5579
1 #include <immintrin.h>
2 #include "m256-check.h"
4 typedef union
6 __m512i x;
7 char a[64];
8 } union512i_b;
10 typedef union
12 __m512i x;
13 short a[32];
14 } union512i_w;
16 typedef union
18 __m512i x;
19 int a[16];
20 } union512i_d;
22 typedef union
24 __m512i x;
25 long long a[8];
26 } union512i_q;
28 typedef union
30 __m512 x;
31 float a[16];
32 } union512;
34 typedef union
36 __m512d x;
37 double a[8];
38 } union512d;
40 typedef union
42 __m512i x;
43 unsigned char a[64];
44 } union512i_ub;
46 typedef union
48 __m512i x;
49 unsigned short a[32];
50 } union512i_uw;
52 typedef union
54 __m512i x;
55 unsigned int a[16];
56 } union512i_ud;
58 typedef union
60 __m512i x;
61 unsigned long long a[8];
62 } union512i_uq;
64 typedef union
66 __m512h x;
67 _Float16 a[32];
68 } union512h;
70 typedef union
72 __m512bh x;
73 unsigned short a[32];
74 } union512bf16_uw;
76 typedef union
78 __m512bh x;
79 __bf16 a[32];
80 } union512bf16_bf;
82 typedef union
84 __m128h x;
85 _Float16 a[8];
86 } union128h;
88 typedef union
90 __m256h x;
91 _Float16 a[16];
92 } union256h;
94 typedef union
96 __m128bh x;
97 unsigned short a[8];
98 } union128bf16_uw;
100 typedef union
102 __m256bh x;
103 unsigned short a[16];
104 } union256bf16_uw;
106 typedef union
108 __m128bh x;
109 __bf16 a[8];
110 } union128bf16_bf;
112 typedef union
114 __m256bh x;
115 __bf16 a[16];
116 } union256bf16_bf;
118 #define CHECK_ROUGH_EXP(UNION_TYPE, VALUE_TYPE, FMT) \
119 static int \
120 __attribute__((noinline, unused)) \
121 check_rough_##UNION_TYPE (UNION_TYPE u, const VALUE_TYPE *v, \
122 VALUE_TYPE eps) \
124 int i; \
125 int err = 0; \
127 for (i = 0; i < ARRAY_SIZE (u.a); i++) \
129 /* We can have have v[i] == 0 == u.a[i] for some i, \
130 when we test zero-masking. */ \
131 if (v[i] == 0.0 && u.a[i] == 0.0) \
132 continue; \
133 if (v[i] == 0.0 && u.a[i] != 0.0) \
135 err++; \
136 PRINTF ("%i: " FMT " != " FMT "\n", \
137 i, v[i], u.a[i]); \
139 VALUE_TYPE rel_err = (u.a[i] - v[i]) / v[i]; \
140 if (((rel_err < 0) ? -rel_err : rel_err) > eps) \
142 err++; \
143 PRINTF ("%i: " FMT " != " FMT "\n", \
144 i, v[i], u.a[i]); \
147 return err; \
150 #ifndef ESP_FLOAT16
151 #define ESP_FLOAT16 0.27
152 #endif
154 CHECK_ROUGH_EXP (union256, float, "%f")
155 CHECK_ROUGH_EXP (union256d, double, "%f")
156 CHECK_ROUGH_EXP (union128, float, "%f")
157 CHECK_ROUGH_EXP (union128d, double, "%f")
159 #ifndef AVX512F_LEN
160 CHECK_EXP (union512i_b, char, "%d")
161 CHECK_EXP (union512i_w, short, "%d")
162 CHECK_EXP (union512i_d, int, "0x%x")
163 CHECK_EXP (union512i_q, long long, "0x%llx")
164 CHECK_EXP (union512, float, "%f")
165 CHECK_EXP (union512d, double, "%f")
166 CHECK_EXP (union512i_ub, unsigned char, "%d")
167 CHECK_EXP (union512i_uw, unsigned short, "%d")
168 CHECK_EXP (union512i_ud, unsigned int, "0x%x")
169 CHECK_EXP (union512i_uq, unsigned long long, "0x%llx")
171 CHECK_FP_EXP (union512, float, ESP_FLOAT, "%f")
172 CHECK_FP_EXP (union512d, double, ESP_DOUBLE, "%f")
174 CHECK_ROUGH_EXP (union512, float, "%f")
175 CHECK_ROUGH_EXP (union512d, double, "%f")
177 #if defined(AVX512FP16)
178 CHECK_EXP (union512h, _Float16, "%f")
179 CHECK_FP_EXP (union512h, _Float16, ESP_FLOAT16, "%f")
180 CHECK_ROUGH_EXP (union512h, _Float16, "%f")
181 #endif
182 #endif
184 #if defined(AVX512FP16)
185 CHECK_EXP (union128h, _Float16, "%f")
186 CHECK_EXP (union256h, _Float16, "%f")
188 CHECK_FP_EXP (union128h, _Float16, ESP_FLOAT16, "%f")
189 CHECK_FP_EXP (union256h, _Float16, ESP_FLOAT16, "%f")
191 CHECK_ROUGH_EXP (union128h, _Float16, "%f")
192 CHECK_ROUGH_EXP (union256h, _Float16, "%f")
193 #endif
195 #if defined(AVX512BF16)
196 CHECK_EXP (union512bf16_uw, unsigned short, "%d")
197 CHECK_EXP (union512bf16_bf, __bf16, "%f")
198 #endif
200 #if defined(AVX512BF16)
201 CHECK_EXP (union128bf16_uw, unsigned short, "%d")
202 CHECK_EXP (union256bf16_uw, unsigned short, "%d")
203 CHECK_EXP (union128bf16_bf, __bf16, "%f")
204 CHECK_EXP (union256bf16_bf, __bf16, "%f")
205 #endif