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