1  /* { dg-require-effective-target vect_condition } */
       2  
       3  #include <stdarg.h>
       4  #include "tree-vect.h"
       5  
       6  #define K 32
       7  
       8  int cond_array[2*K][K] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
       9  int a[K][K] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
      10  int out[K];
      11  int check_result[K] = {2,2,2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
      12  
      13  __attribute__ ((noinline)) void 
      14  foo (int c)
      15  {
      16    int res, i, j, k, next;
      17  
      18    for (k = 0; k < K; k++)
      19      {
      20        res = 0;
      21        for (j = 0; j < K; j++) 
      22          for (i = 0; i < K; i++)
      23            { 
      24              next = a[i][j]; 
      25              res = c > cond_array[i+k][j] ? next : res;
      26            }
      27   
      28        out[k] = res;
      29      }
      30  }
      31  
      32  int main ()
      33  {
      34    int i, j, k;
      35  
      36    check_vect ();
      37  
      38    for  (j = 0; j < K; j++)
      39      {
      40        for (i = 0; i < 2*K; i++)
      41          cond_array[i][j] = i+j;
      42  
      43        for (i = 0; i < K; i++)
      44          a[i][j] = i+2;
      45      }
      46  
      47    foo(5);
      48  
      49    for (k = 0; k < K; k++)
      50      if (out[k] != check_result[k])
      51        abort ();
      52  
      53    return 0;
      54  }
      55  
      56  /* Double reduction with cond_expr is not supported, since even though the order 
      57     of computation is the same, but vector results should be reduced to scalar
      58     result, which can'be done for cond_expr.  */
      59  /* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" { xfail *-*-* } } } */
      60