(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
vect/
vect-simd-clone-6.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];
      12  long long int b[N];
      13  short c[N];
      14  
      15  #pragma omp declare simd
      16  #pragma omp declare simd uniform(b) linear(c:3)
      17  __attribute__((noinline)) short
      18  foo (int a, long long int b, short c)
      19  {
      20    return a + b + c;
      21  }
      22  
      23  __attribute__((noinline, noclone)) void
      24  bar (int x)
      25  {
      26    int i;
      27    if (x == 0)
      28      {
      29      #pragma omp simd
      30        for (i = 0; i < N; i++)
      31  	c[i] = foo (a[i], b[i], c[i]);
      32      }
      33    else
      34      {
      35      #pragma omp simd
      36        for (i = 0; i < N; i++)
      37  	c[i] = foo (a[i], x, i * 3);
      38      }
      39  }
      40  
      41  __attribute__((noinline, noclone)) void
      42  baz (void)
      43  {
      44    int i;
      45    for (i = 0; i < N; i++)
      46      {
      47        a[i] = 2 * i;
      48        b[i] = -7 * i + 6;
      49        c[i] = (i & 31) << 4;
      50      }
      51  }
      52  
      53  int
      54  main ()
      55  {
      56    int i;
      57    check_vect ();
      58    baz ();
      59    bar (0);
      60    for (i = 0; i < N; i++)
      61      if (a[i] != 2 * i || b[i] != 6 - 7 * i
      62  	|| c[i] != 6 - 5 * i + ((i & 31) << 4))
      63        abort ();
      64      else
      65        a[i] = c[i];
      66    bar (17);
      67    for (i = 0; i < N; i++)
      68      if (a[i] != 6 - 5 * i + ((i & 31) << 4)
      69  	|| b[i] != 6 - 7 * i
      70  	|| c[i] != 23 - 2 * i + ((i & 31) << 4))
      71        abort ();
      72    return 0;
      73  }
      74