Imported Upstream version 4.7.3
[platform/upstream/gcc48.git] / gcc / testsuite / gcc.dg / vect / vect-cselim-2.c
1 /* { dg-require-effective-target vect_int } */
2
3 #include <stdarg.h>
4 #include "tree-vect.h"
5
6 #define N 50
7
8 int a[N], b[N], in1[N], in2[N];
9 int result[2*N] = {5,-7,7,-6,9,-5,11,-4,13,-3,15,-2,17,-1,19,0,21,1,23,2,25,3,27,4,29,5,31,6,33,7,35,8,37,9,39,10,41,11,43,12,45,13,47,14,49,15,51,16,53,17,55,18,57,19,59,20,61,21,63,22,65,23,67,24,69,25,71,26,73,27,75,28,77,29,79,30,81,31,83,32,85,33,87,34,89,35,91,36,93,37,95,38,97,39,99,40,101,41,103,42};
10
11 __attribute__ ((noinline)) void
12 foo (int *pa, int *pb)
13 {
14   int i;
15   int c, d;
16
17   /* Store sinking should not work here since the pointers may alias.  */
18   for (i = 0; i < N; i++)
19     {
20       c = in1[i];
21       d = in2[i];
22
23       if (c >= d)
24         {
25           *pa = c;
26           *pb = d + 5;
27         }
28       else
29         {
30           *pb = d - 12;
31           *pa = c + d;
32         }
33
34       pa++;
35       pb++;
36     }
37 }
38
39 int
40 main (void)
41 {
42   int i;
43
44   check_vect ();
45
46   for (i = 0; i < N; i++)
47     {
48       in1[i] = i;
49       in2[i] = i + 5;
50       __asm__ volatile ("");
51     }
52
53   foo (a, b);
54
55   for (i = 0; i < N; i++)
56     {
57       if (a[i] != result[2*i] || b[i] != result[2*i+1])
58         abort ();
59     }
60
61   return 0;
62 }
63
64 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect"  } } */
65 /* { dg-final { cleanup-tree-dump "vect" } } */