2018-05-17 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / tree-ssa / ssa-pre-19.c
blobbb6300d5c8d71a53e1c1c1cc11c57a0796d6af22
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" } } */