(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
vect/
pr65947-2.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 254
       8  
       9  /* Non-simple condition reduction.  */
      10  
      11  unsigned char
      12  condition_reduction (unsigned char *a, unsigned char min_v)
      13  {
      14    unsigned char last = 65;
      15  
      16    for (unsigned char i = 0; i < N; i++)
      17      if (a[i] < min_v)
      18        last = a[i];
      19  
      20    return last;
      21  }
      22  
      23  int
      24  main (void)
      25  {
      26    unsigned char a[N] = {
      27    11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
      28    1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
      29    21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
      30    31, 32
      31    };
      32    __builtin_memset (a+32, 43, N-32);
      33  
      34    check_vect ();
      35  
      36    unsigned char ret = condition_reduction (a, 16);
      37  
      38    if (ret != 10)
      39      abort ();
      40  
      41    return 0;
      42  }
      43  
      44  /* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 2 "vect" } } */
      45  /* { dg-final { scan-tree-dump-times "optimizing condition reduction with FOLD_EXTRACT_LAST" 2 "vect" { target vect_fold_extract_last } } } */
      46  /* { dg-final { scan-tree-dump-not "condition expression based on integer induction." "vect" } } */