Merge branches/gcc-4_9-branch rev 225109.
[official-gcc.git] / gcc-4_9-branch / gcc / testsuite / gcc.dg / vect / vect-cond-3.c
blob0f36e848b5552551fd256062c0e9890149e99d3c
1 /* { dg-require-effective-target vect_condition } */
3 #include <stdlib.h>
4 #include "tree-vect.h"
6 #define M 32
7 #define N 16
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};
17 __attribute__ ((noinline)) void
18 foo ()
20 int j, i, x;
21 int curr_a, flag, next_a, curr_b, next_b;
23 for (j = 0; j < M; j++)
25 x = x_in[j];
26 curr_a = a[0];
27 curr_b = b[0];
29 for (i = 0; i < N; i++)
31 flag = x > c[i];
32 next_a = a[i+1];
33 next_b = b[i+1];
34 curr_a = flag ? curr_a : next_a;
35 curr_b = flag ? next_b : curr_b;
38 x_out_a[j] = curr_a;
39 x_out_b[j] = curr_b;
43 int main (void)
45 int i,j;
47 check_vect ();
49 for (j = 0; j < M; j++)
50 x_in[j] = j;
52 foo ();
54 for (j = 0; j < M; j++)
55 if (x_out_a[j] != check_result_a[j]
56 || x_out_b[j] != check_result_b[j])
57 abort ();
59 return 0;
62 /* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" { xfail { vect_no_align && { ! vect_hw_misalign } } } } } */
63 /* { dg-final { cleanup-tree-dump "vect" } } */