(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.target/
i386/
avx-cvt-2-vec.c
       1  /* { dg-do run } */
       2  /* { dg-options "-O2 -ffast-math -ftree-vectorize -mavx" } */
       3  /* { dg-require-effective-target avx } */
       4  
       5  #ifndef CHECK_H
       6  #define CHECK_H "avx-check.h"
       7  #endif
       8  
       9  #ifndef TEST
      10  #define TEST avx_test
      11  #endif
      12  
      13  #include CHECK_H
      14  
      15  #include "math_m_pi.h"
      16  
      17  #define NUM 4
      18  
      19  static void
      20  __attribute__((__target__("fpmath=sse")))
      21  init_src (double *src)
      22  {
      23    int i, sign = 1;
      24    double f = rand ();
      25  
      26    for (i = 0; i < NUM; i++)
      27      {
      28        src[i] = (i + 1) * f * M_PI * sign;
      29        if (i < (NUM / 2))
      30  	{
      31            if ((i % 6) == 0)
      32  	    f = f * src[i];
      33          }
      34        else if (i == (NUM / 2))
      35  	f = rand ();
      36        else if ((i % 6) == 0)
      37  	f = 1 / (f * (i + 1) * src[i] * M_PI * sign);
      38        sign = -sign;
      39      }
      40  }
      41  
      42  static void
      43  __attribute__((__target__("fpmath=sse")))
      44  TEST (void)
      45  {
      46    double a[NUM];
      47    float r[NUM];
      48    int i;
      49  
      50    init_src (a);
      51  
      52    for (i = 0; i < NUM; i++)
      53      r[i] = (float) a[i];
      54  
      55    /* check results:  */
      56    for (i = 0; i < NUM; i++)
      57      if (r[i] != (float) a[i])
      58        abort();
      59  }