(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
autopar/
reduc-3.c
       1  /* { dg-do compile } */
       2  /* { dg-options "-O2 -ftree-parallelize-loops=4 -fdump-tree-parloops2-details -fdump-tree-optimized" } */
       3  
       4  #include <stdarg.h>
       5  #include <stdlib.h>
       6  
       7  #define N 1600
       8  
       9  unsigned int ub[N];
      10  unsigned int uc[N];
      11  
      12  /* Reduction of unsigned-int.  */
      13  
      14  __attribute__ ((noinline))
      15  int main1 (int n, int res)
      16  {
      17    int i;
      18    unsigned int udiff;
      19  
      20    udiff = 0;
      21    for (i = 0; i < n; i++) {
      22      udiff += (ub[i] - uc[i]);
      23    }
      24  
      25    /* check results:  */
      26    if (udiff != res)
      27      abort ();
      28  
      29    return 0;
      30  }
      31  
      32  __attribute__((noinline))
      33  void init_arrays ()
      34  {
      35    int i;
      36    
      37    for (i=0; i<N; i++)
      38      {
      39        ub[i] = i * 3;
      40        uc[i] = i;
      41      }
      42  }
      43  
      44  int main (void)
      45  { 
      46    init_arrays ();
      47    main1 (N, 2558400);
      48    main1 (N-1, 2555202);
      49    return 0;
      50  }
      51  
      52  
      53  /* { dg-final { scan-tree-dump-times "Detected reduction" 1 "parloops2" } } */
      54  /* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 2 "parloops2" } } */
      55