Imported Upstream version 4.7.3
[platform/upstream/gcc48.git] / gcc / testsuite / gcc.dg / vect / vect-cond-6.c
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
12 __attribute__ ((noinline)) void 
13 foo (int c)
14 {
15   int res, i, j, k, next;
16
17   for (k = 0; k < K; k++)
18     {
19       for (j = 0; j < K; j++) 
20         {
21           res = 0;
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[j] = res;
29         }
30     }
31 }
32
33 int main ()
34 {
35   int i, j, k;
36
37   check_vect ();
38
39   for  (j = 0; j < K; j++)
40     {
41       for (i = 0; i < 2*K; i++)
42         cond_array[i][j] = i+j;
43
44       for (i = 0; i < K; i++)
45         a[i][j] = i+2;
46     }
47
48   foo(125);
49
50   for (k = 0; k < K; k++) 
51     if (out[k] != 33)
52       abort ();
53
54   return 0;
55 }
56
57 /* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" } } */
58 /* { dg-final { cleanup-tree-dump "vect" } } */
59