Imported Upstream version 4.7.3
[platform/upstream/gcc48.git] / gcc / testsuite / gcc.dg / vect / vect-cond-4.c
1 /* { dg-require-effective-target vect_condition } */
2
3 #include <stdlib.h> 
4 #include "tree-vect.h"
5
6 #define M 32
7 #define N 16
8
9 int x_in[M];
10 int x_out_a[M], x_out_b[M];
11 int c[N] = {3,2,1,10,1,42,3,4,50,9,32,8,11,10,1,2};
12 int a[N+1] = {0,16,32,48,64,128,256,512,0,16,32,48,64,128,256,512,1024};
13 int b[N+1] = {17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1};
14 int check_result_a[M] = {1024,1024,1024,256,256,256,256,256,256,256,256,128,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48};
15 int check_result_b[M] = {17,17,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
16
17 __attribute__ ((noinline)) void 
18 foo (int z)
19 {
20   int j, i, x;
21   int curr_a, curr_b;
22
23   for (j = 0; j < M; j++) 
24     {
25       x = x_in[j];
26       curr_a = a[0];
27       curr_b = b[0];
28
29       for (i = 0; i < N; i++) 
30         {
31           curr_a = x > c[i] ? curr_a : z;
32           curr_b = x > c[i] ? curr_b : 5;
33         }
34
35       x_out_a[j] = curr_a;
36       x_out_b[j] = curr_b;
37     }
38 }
39
40 int main (void)
41 {
42   int i,j;
43
44   check_vect ();
45
46   for (j = 0; j < M; j++) 
47     x_in[j] = j;
48
49   foo (125);
50
51   for (j = 0; j < M; j++)
52     if (x_out_a[j] != 125
53         || x_out_b[j] != 5)
54       abort ();
55
56   return 0;
57 }
58
59 /* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" { xfail vect_no_align } } } */
60 /* { dg-final { cleanup-tree-dump "vect" } } */
61
62