re PR tree-optimization/33291 (a+=2; a+=2 not simplified to a+=4; with -O3 ...
[gcc.git] / gcc / testsuite / gcc.dg / tree-ssa / pr23234.c
1 /* The problem in this PR was mostly finding a suitable place to insert
2 the reciprocals of the function arguments. This test case tries to
3 test three possible ways of how this may go wrong. */
4 /* { dg-options "-O2 -ffast-math" } */
5 /* { dg-do compile } */
6
7 /* The original test case. */
8 double
9 f1 (double a, double b, double c)
10 {
11 double y0;
12 double y1;
13
14 if (a == 0.0)
15 {
16 y0 = -c / b;
17 return y0;
18 }
19 y0 = c / b;
20 y1 = a / b;
21 return y0 * y1;
22 }
23
24 /* Labels may end up in the middle of a block. Also bad. */
25 double
26 f2 (double a, double b, double c)
27 {
28 double y0;
29 double y1;
30
31 a_label:
32 another_label:
33 if (a == 0.0)
34 {
35 y0 = -c / b;
36 return y0;
37 }
38 y0 = c / b;
39 y1 = a / b;
40 return y0 * y1;
41 }
42
43 /* Uses must still be dominated by their defs. */
44 double
45 f3 (double a, double b, double c)
46 {
47 double y0;
48 double y1;
49
50 y0 = -c / b;
51 if (a == 0.0)
52 {
53 return y0;
54 }
55 y0 = c / b;
56 y1 = a / b;
57 return y0 * y1;
58 }