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 43
       8  
       9  /* Condition reduction with comparison is a different type to the data.  Will
      10     fail to vectorize.  */
      11  
      12  int __attribute__ ((noipa))
      13  condition_reduction (short *a, int min_v, int *b)
      14  {
      15    int last = N + 65;
      16    short aval;
      17  
      18    for (int i = 0; i < N; i++)
      19      {
      20        aval = a[i];
      21        if (b[i] < min_v)
      22  	last = aval;
      23      }
      24    return last;
      25  }
      26  
      27  int
      28  main (void)
      29  {
      30    short a[N] = {
      31    31, -32, 133, 324, 335, 36, 37, 45, 11, 65,
      32    1, -28, 3, 48, 5, -68, 7, 88, 89, 180,
      33    121, -122, 123, 124, -125, 126, 127, 128, 129, 130,
      34    11, 12, 13, 14, -15, -16, 17, 18, 19, 20,
      35    33, 27, 99
      36    };
      37    int b[N] = {
      38    11, -12, -13, 14, 15, 16, 17, 18, 19, 20,
      39    21, -22, 23, 24, -25, 26, 27, 28, 29, 30,
      40    1, 62, 3, 14, -15, 6, 37, 48, 99, 10,
      41    31, -32, 33, 34, -35, 36, 37, 56, 54, 22,
      42    73, 2, 87
      43    };
      44  
      45    check_vect ();
      46  
      47    int ret = condition_reduction (a, 16, b);
      48  
      49    if (ret != 27)
      50      abort ();
      51  
      52    return 0;
      53  }
      54  
      55  /* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { target vect_fold_extract_last } } } */
      56  /* { dg-final { scan-tree-dump-not "LOOP VECTORIZED" "vect" { target { ! vect_fold_extract_last } } } } */