Merge from mainline
[official-gcc.git] / gcc / testsuite / g++.dg / tree-ssa / ssa-sra-2.C
blobd73787018e7fbb472e95dd33d8f1bc48524f833d
1 /* { dg-do compile } */
2 /* { dg-options "-O1 -fdump-tree-optimized" } */
4 void link_error();
6 struct OOf {
7         int value;
8         OOf() {value = 0;}
9 };
10 inline OOf operator+(OOf op1, OOf op2)
12         OOf f;
13         f.value = op1.value + op2.value;
14         return f;
16 inline OOf operator*(OOf op1, OOf op2)
18         OOf f;
19         f.value = op1.value * op2.value;
20         return f;
22 inline OOf operator-(OOf op1, OOf op2)
24         OOf f;
25         f.value = op1.value - op2.value;
26         return f;
28 inline OOf test_func(
29         OOf a,
30         OOf b,
31         OOf c
34         OOf d, e;
35         OOf result;
36         d = a * b + b * c;
37         e = a * c - b * d;
38         result = d * e;
39         return result;
42 void test()
44   OOf a, b, c;
45   OOf d = test_func (a,b,c);
46   if (d.value)
47     link_error();
50 /* We should have removed the casts from pointers to references and caused SRA to happen.  */
51 /* { dg-final { scan-tree-dump-times "link_error" 0 "optimized"} } */
52 /* { dg-final { cleanup-tree-dump "optimized" } } */