(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
vect/
vect-simd-19.c
       1  /* { dg-additional-options "-fopenmp-simd -fno-tree-vectorize" } */
       2  /* { dg-additional-options "-mavx" { target avx_runtime } } */
       3  /* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { target i?86-*-* x86_64-*-* } } } */
       4  
       5  #include "tree-vect.h"
       6  
       7  __attribute__((noipa)) int
       8  foo (int s, int m, int n, int *p)
       9  {
      10    int r = 0, l = 0, i;
      11    #pragma omp simd reduction (+:r) linear(l)
      12    for (i = m; i < n; i += s)
      13      {
      14        p[l++] = i;
      15        r += i * 3;
      16      }
      17    return r;
      18  }
      19  
      20  int p[10000 / 78 + 1];
      21  
      22  int
      23  main ()
      24  {
      25    int i, r;
      26    check_vect ();
      27    r = foo (78, 0, 10000, p);
      28    for (i = 0; i < 10000 / 78; i++)
      29      if (p[i] != 78 * i)
      30        abort ();
      31    if (r != (10000 / 78) * (10000 / 78 + 1) / 2 * 78 * 3)
      32      abort ();
      33    r = foo (87, 0, 10000, p);
      34    for (i = 0; i < 10000 / 87; i++)
      35      if (p[i] != 87 * i)
      36        abort ();
      37    if (r != (10000 / 87) * (10000 / 87 + 1) / 2 * 87 * 3)
      38      abort ();
      39    return 0;
      40  }