PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / avx512er-vrsqrt28ps-5.c
blobe067a81e5620b7203ba4ed0732f57294f573768f
1 /* { dg-do run } */
2 /* { dg-require-effective-target avx512er } */
3 /* { dg-options "-O2 -ffast-math -ftree-vectorize -mavx512er" } */
5 #include <math.h>
6 #include "avx512er-check.h"
8 #define MAX 1000
9 #define EPS 0.00001
11 __attribute__ ((noinline, optimize (1)))
12 void static
13 compute_sqrt_ref (float *a, float *r)
15 for (int i = 0; i < MAX; i++)
16 r[i] = sqrtf (a[i]);
19 __attribute__ ((noinline))
20 void static
21 compute_sqrt_exp (float *a, float *r)
23 for (int i = 0; i < MAX; i++)
24 r[i] = sqrtf (a[i]);
27 void static
28 avx512er_test (void)
30 float in[MAX];
31 float ref[MAX];
32 float exp[MAX];
34 for (int i = 0; i < MAX; i++)
35 in[i] = 8765.987 - 8.6756 * i;
37 compute_sqrt_ref (in, ref);
38 compute_sqrt_exp (in, exp);
40 for (int i = 0; i < MAX; i++)
42 float rel_err = (ref[i] - exp[i]) / ref[i];
43 rel_err = rel_err > 0.0 ? rel_err : -rel_err;
44 if (rel_err > EPS)
45 abort ();