1 /* { dg-do run } */
2 /* { dg-options "-O2 -funroll-loops --param max-unroll-times=8 -fpredictive-commoning -fdump-tree-pcom-details" } */
3
4 /* Test for predictive commoning of expressions, with reassociation. */
5
6 void abort (void);
7
8 unsigned a[1000], b[1000], c[1000], d[1000];
9
main(void)10 int main(void)
11 {
12 unsigned i;
13
14 for (i = 0; i < 1000; i++)
15 a[i] = b[i] = d[i] = i;
16
17 for (i = 1; i < 998; i++)
18 c[i] = d[i + 1] * a[i + 2] * b[i + 1] - b[i - 1] * a[i] * d[i - 1];
19
20 for (i = 1; i < 998; i++)
21 if (c[i] != (i+1)*(i+2)*(i+1) - (i - 1) * i * (i - 1))
22 abort ();
23
24 return 0;
25 }
26
27 /* { dg-final { scan-tree-dump-times "Combination" 2 "pcom"} } */
28 /* { dg-final { scan-tree-dump-times "Unrolling 3 times." 1 "pcom"} } */
29