(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
vect/
pr65947-11.c
       1  /* { dg-require-effective-target vect_condition } */
       2  
       3  #include "tree-vect.h"
       4  
       5  extern void abort (void) __attribute__ ((noreturn));
       6  
       7  #define N 37
       8  
       9  /* Re-use the result of the condition inside the loop.  Will fail to
      10     vectorize.  */
      11  
      12  unsigned int
      13  condition_reduction (unsigned int *a, unsigned int min_v, unsigned int *b)
      14  {
      15    unsigned int last = N + 65;
      16  
      17    for (unsigned int i = 0; i < N; i++)
      18      {
      19        if (b[i] < min_v)
      20  	last = i;
      21        a[i] = last;
      22      }
      23    return last;
      24  }
      25  
      26  int
      27  main (void)
      28  {
      29    unsigned int a[N] = {
      30    31, 32, 33, 34, 35, 36, 37,
      31    1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
      32    21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
      33    11, 12, 13, 14, 15, 16, 17, 18, 19, 20
      34    };
      35    unsigned int b[N] = {
      36    11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
      37    21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
      38    1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
      39    31, 32, 33, 34, 35, 36, 37
      40    };
      41  
      42    check_vect ();
      43  
      44    unsigned int ret = condition_reduction (a, 16, b);
      45  
      46    if (ret != 29)
      47      abort ();
      48  
      49    return 0;
      50  }
      51  
      52  /* { dg-final { scan-tree-dump-not "LOOP VECTORIZED" "vect" } } */