Imported Upstream version 4.7.3
[platform/upstream/gcc48.git] / gcc / testsuite / gcc.dg / vect / vect-cond-2.c
1 /* { dg-require-effective-target vect_condition } */
2
3 #include <stdlib.h> 
4 #include "tree-vect.h"
5
6 #define N 16
7
8 int c[N] = {3,2,1,10,1,42,3,4,50,9,32,8,11,10,1,2};
9 int a[N+1] = {0,16,32,48,64,128,256,512,0,16,32,48,64,128,256,512,1024};
10
11 __attribute__ ((noinline)) void 
12 foo (int *x)
13 {
14   int i;
15   int curr_a, flag, next_a;
16
17   curr_a = a[0];
18
19   for (i = 0; i < N; i++) 
20     {
21       flag = *x > c[i];
22       next_a = a[i+1];
23       curr_a = flag ? curr_a : next_a;
24     }
25
26   *x = curr_a;
27 }
28
29 int main (void)
30 {
31   int x = 7;
32
33   check_vect ();
34
35   foo (&x);
36
37   if (x != 256)
38     abort ();
39
40   return 0;
41 }
42
43 /* The order of computation should not be changed for cond_expr, therefore, 
44    it cannot be vectorized in reduction.  */
45 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */
46 /* { dg-final { cleanup-tree-dump "vect" } } */
47
48