1 /* { dg-do compile } */
2 /* { dg-options "-O2 -fdump-tree-reassoc1" } */
3
f1(unsigned x,unsigned z)4 unsigned f1 (unsigned x, unsigned z)
5 {
6 unsigned y = x + z;
7 y = y + x;
8 y = y + x;
9 y = y + x;
10 y = y + x;
11 y = y + x;
12 y = y + x;
13 return y;
14 }
15
16 /* { dg-final { scan-tree-dump-times "\\\* 7" 1 "reassoc1" } } */
17
f2(unsigned x,unsigned z)18 unsigned f2 (unsigned x, unsigned z)
19 {
20 unsigned y = x + z;
21 y = y + x;
22 y = y + x;
23 y = y + x;
24 y = y + z;
25 y = y + z;
26 y = y + z;
27 y = y + z;
28 return y;
29 }
30
31 /* { dg-final { scan-tree-dump-times "\\\* 5" 1 "reassoc1" } } */
32 /* { dg-final { scan-tree-dump-times "\\\* 4" 1 "reassoc1" } } */
33
f3(unsigned x,unsigned z,unsigned k)34 unsigned f3 (unsigned x, unsigned z, unsigned k)
35 {
36 unsigned y = x + z;
37 y = y + x;
38 y = y + z;
39 y = y + z;
40 y = y + k;
41 return y;
42 }
43
44 /* { dg-final { scan-tree-dump-times "\\\* 2" 1 "reassoc1" } } */
45 /* { dg-final { scan-tree-dump-times "\\\* 3" 1 "reassoc1" } } */
46
f4(unsigned x,unsigned z,unsigned k)47 unsigned f4 (unsigned x, unsigned z, unsigned k)
48 {
49 unsigned y = k + x;
50 y = y + z;
51 y = y + z;
52 y = y + z;
53 y = y + z;
54 y = y + z;
55 y = y + z;
56 y = y + z;
57 y = y + z;
58 return y;
59 }
60 /* { dg-final { scan-tree-dump-times "\\\* 8" 1 "reassoc1" } } */
61
f5(unsigned x,unsigned y,unsigned z)62 unsigned f5 (unsigned x, unsigned y, unsigned z)
63 {
64 return x + y + y + y + y + y \
65 + y + z + z + z + z + z + z + z + z + z;
66 }
67
68 /* { dg-final { scan-tree-dump-times "\\\* 6" 1 "reassoc1" } } */
69 /* { dg-final { scan-tree-dump-times "\\\* 9" 1 "reassoc1" } } */
70
71