Imported Upstream version 4.7.3
[platform/upstream/gcc48.git] / gcc / testsuite / gcc.dg / vect / vect-cond-1.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[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 check_result[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};
14
15 __attribute__ ((noinline)) void 
16 foo ()
17 {
18   int j, i, x;
19   int curr_a, next_a;
20
21   for (j = 0; j < M; j++) 
22     {
23       x = x_in[j];
24       curr_a = a[0];
25
26       for (i = 0; i < N; i++) 
27         {
28           next_a = a[i+1];
29           curr_a = x > c[i] ? curr_a : next_a;
30         }
31
32       x_out[j] = curr_a;
33     }
34 }
35
36 int main (void)
37 {
38   int i,j;
39
40   check_vect ();
41
42   for (j = 0; j < M; j++) 
43     x_in[j] = j;
44
45   foo ();
46
47   for (j = 0; j < M; j++)
48     if (x_out[j] != check_result[j])
49       abort ();
50
51   return 0;
52 }
53
54 /* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" { xfail vect_no_align } } } */
55 /* { dg-final { cleanup-tree-dump "vect" } } */
56
57