OSDN Git Service

* gcc.dg/vect/vect-105.c: Prevent compiler from hoisting abort
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / tree-ssa / ssa-pre-19.c
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -fdump-tree-pre-stats" } */
3
4 struct Loc {
5     int x[3];
6 };
7
8 void bar (struct Loc *);
9
10 int foo (int i, int j, int k, int b)
11 {
12   struct Loc IND;
13   int res;
14
15   if (b)
16     {
17       IND.x[0] = i;
18       IND.x[1] = j;
19       IND.x[2] = k-1;
20     }
21   else
22     {
23       IND.x[0] = i;
24       IND.x[1] = j;
25       IND.x[2] = k;
26     }
27
28   /* This should be optimized to i + j + {k, k + 1}.  */
29   res = IND.x[0] + IND.x[1] + IND.x[2];
30
31   /* This is just to prevent SRA.  */
32   bar (&IND);
33
34   return res;
35 }
36
37 /* All three loads should be eliminated.  */
38 /* { dg-final { scan-tree-dump "Eliminated: 3" "pre" } } */
39 /* { dg-final { cleanup-tree-dump "pre" } } */