(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.target/
i386/
avx512er-vrsqrt28ps-5.c
       1  /* { dg-do run } */
       2  /* { dg-require-effective-target avx512er } */
       3  /* { dg-options "-O2 -ffast-math -ftree-vectorize -mavx512er" } */
       4  
       5  #include <math.h>
       6  #include "avx512er-check.h"
       7  
       8  #define MAX 1000
       9  #define EPS 0.00001
      10  
      11  __attribute__ ((noinline, optimize (1, "-fno-fast-math")))
      12  void static
      13  compute_sqrt_ref (float *a, float *r)
      14  {
      15    for (int i = 0; i < MAX; i++)
      16      r[i] = sqrtf (a[i]);
      17  }
      18  
      19  __attribute__ ((noinline))
      20  void static
      21  compute_sqrt_exp (float *a, float *r)
      22  {
      23    for (int i = 0; i < MAX; i++)
      24      r[i] = sqrtf (a[i]);
      25  }
      26  
      27  void static
      28  avx512er_test (void)
      29  {
      30    float in[MAX];
      31    float ref[MAX];
      32    float exp[MAX];
      33  
      34    for (int i = 0; i < MAX; i++)
      35      in[i] = 8765.987 - 8.6756 * i;
      36  
      37    compute_sqrt_ref (in, ref);
      38    compute_sqrt_exp (in, exp);
      39  
      40    for (int i = 0; i < MAX; i++)
      41      {
      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 ();
      46      }
      47  }