PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / avx512er-vrcp28ps-3.c
blobe08bea41c3e3f634df4cf109637a1190c041e3be
1 /* { dg-do run } */
2 /* { dg-require-effective-target avx512er } */
3 /* { dg-options "-O2 -ffast-math -ftree-vectorize -mavx512er" } */
5 #include "avx512er-check.h"
7 #define MAX 1000
8 #define EPS 0.00001
10 __attribute__ ((noinline, optimize (0)))
11 void static
12 compute_rcp_ref (float *a, float *b, float *r)
14 for (int i = 0; i < MAX; i++)
15 r[i] = a[i] / b[i];
18 __attribute__ ((noinline))
19 void static
20 compute_rcp_exp (float *a, float *b, float *r)
22 for (int i = 0; i < MAX; i++)
23 r[i] = a[i] / b[i];
26 void static
27 avx512er_test (void)
29 float a[MAX];
30 float b[MAX];
31 float ref[MAX];
32 float exp[MAX];
34 for (int i = 0; i < MAX; i++)
36 a[i] = 179.345 - 6.5645 * i;
37 b[i] = 8765.987 - 8.6756 * i;
40 compute_rcp_ref (a, b, ref);
41 compute_rcp_exp (a, b, exp);
43 for (int i = 0; i < MAX; i++)
45 float rel_err = (ref[i] - exp[i]) / ref[i];
46 rel_err = rel_err > 0.0 ? rel_err : -rel_err;
47 if (rel_err > EPS)
48 abort ();