PR testsuite/52641
[official-gcc.git] / gcc / testsuite / gcc.dg / tree-ssa / ssa-pre-19.c
blob0fd0dc5425cc5fe6e93ca525c2625c5163f2cf8e
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -fdump-tree-pre-stats" } */
4 struct Loc {
5 int x[3];
6 };
8 void bar (struct Loc *);
10 int foo (int i, int j, int k, int b)
12 struct Loc IND;
13 int res;
15 if (b)
17 IND.x[0] = i;
18 IND.x[1] = j;
19 IND.x[2] = k-1;
21 else
23 IND.x[0] = i;
24 IND.x[1] = j;
25 IND.x[2] = k;
28 /* This should be optimized to i + j + {k, k + 1}. */
29 res = IND.x[0] + IND.x[1] + IND.x[2];
31 /* This is just to prevent SRA. */
32 bar (&IND);
34 return res;
37 /* All three loads should be eliminated. */
38 /* { dg-final { scan-tree-dump "Eliminated: 3" "pre" } } */
39 /* { dg-final { cleanup-tree-dump "pre" } } */