(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
vect/
vect-simd-clone-9.c
       1  /* { dg-require-effective-target vect_simd_clones } */
       2  /* { dg-additional-options "-fopenmp-simd" } */
       3  /* { dg-additional-options "-mavx" { target avx_runtime } } */
       4  
       5  #include "tree-vect.h"
       6  
       7  #ifndef N
       8  #define N 1024
       9  #endif
      10  
      11  int a[N], b[N];
      12  long int c[N];
      13  unsigned char d[N];
      14  
      15  #pragma omp declare simd notinbranch
      16  __attribute__((noinline)) static int
      17  foo (long int a, int b, int c)
      18  {
      19    return a + b + c;
      20  }
      21  
      22  #pragma omp declare simd notinbranch
      23  __attribute__((noinline)) static long int
      24  bar (int a, int b, long int c)
      25  {
      26    return a + b + c;
      27  }
      28  
      29  __attribute__((noinline)) void
      30  fn1 (void)
      31  {
      32    int i;
      33    #pragma omp simd
      34    for (i = 0; i < N; i++)
      35      a[i] = foo (c[i], a[i], b[i]) + 6;
      36    #pragma omp simd
      37    for (i = 0; i < N; i++)
      38      c[i] = bar (a[i], b[i], c[i]) * 2;
      39  }
      40  
      41  __attribute__((noinline)) void
      42  fn2 (void)
      43  {
      44    int i;
      45    #pragma omp simd
      46    for (i = 0; i < N; i++)
      47      {
      48        a[i] = foo (c[i], a[i], b[i]) + 6;
      49        d[i]++;
      50      }
      51    #pragma omp simd
      52    for (i = 0; i < N; i++)
      53      {
      54        c[i] = bar (a[i], b[i], c[i]) * 2;
      55        d[i] /= 2;
      56      }
      57  }
      58  
      59  __attribute__((noinline)) void
      60  fn3 (void)
      61  {
      62    int i;
      63    for (i = 0; i < N; i++)
      64      {
      65        a[i] = i * 2;
      66        b[i] = 17 + (i % 37);
      67        c[i] = (i & 63);
      68        d[i] = 16 + i;
      69      }
      70  }
      71  
      72  int
      73  main ()
      74  {
      75    int i;
      76    check_vect ();
      77    fn3 ();
      78    fn1 ();
      79    for (i = 0; i < N; i++)
      80      if (a[i] != i * 2 + 23 + (i % 37) + (i & 63)
      81  	|| b[i] != 17 + (i % 37)
      82  	|| c[i] != i * 4 + 80 + 4 * (i % 37) + 4 * (i & 63))
      83        abort ();
      84    fn3 ();
      85    fn2 ();
      86    for (i = 0; i < N; i++)
      87      if (a[i] != i * 2 + 23 + (i % 37) + (i & 63)
      88  	|| b[i] != 17 + (i % 37)
      89  	|| c[i] != i * 4 + 80 + 4 * (i % 37) + 4 * (i & 63)
      90  	|| d[i] != ((unsigned char) (17 + i)) / 2)
      91        abort ();
      92    return 0;
      93  }
      94