1 /* { dg-do compile } */
2 /* { dg-options "-O1 -ffinite-math-only -fno-signed-zeros -fdump-tree-phiopt1" } */
3 
repl1(float varx)4 float repl1 (float varx)
5 {
6   if (varx < 0.0)
7     return 0.0;
8   else if (varx > 1.0)
9     return 1.0;
10   else
11     return varx;
12 }
13 
14 /* Should be turned to
15 
16    varx_4 = MIN_EXPR <1.0e+0, varx_2>;
17    varx_5 = MAX_EXPR <varx_4, 0.0>;  */
18 
19 /* { dg-final { scan-tree-dump "varx.*MIN_EXPR.*1\\.0" "phiopt1"} } */
20 /* { dg-final { scan-tree-dump "varx.*MAX_EXPR.*0\\.0" "phiopt1"} } */
21 
repl2(float vary)22 float repl2 (float vary)
23 {
24   if (vary > 1.0)
25     return 1.0;
26   else if (vary < 0.0)
27     return 0.0;
28   else
29     return vary;
30 }
31 
32 /* Should be turned to
33 
34    vary_4 = MAX_EXPR <0.0, vary_2>;
35    vary_5 = MIN_EXPR <vary_4, 1.0e+0>;  */
36 
37 /* { dg-final { scan-tree-dump "vary.*MAX_EXPR.*0\\.0" "phiopt1"} } */
38 /* { dg-final { scan-tree-dump "vary.*MIN_EXPR.*1\\.0" "phiopt1"} } */
39 
repl3(float varz,float vara,float varb)40 float repl3 (float varz, float vara, float varb)
41 {
42   if (varz > vara)
43     return vara;
44   else if (varz < varb)
45     return varb;
46   else
47     return varz;
48 }
49 
50 /* Should be turned to
51 
52   if (varz_2 > vara_3) goto <L4>; else goto <L1>;
53 
54 <L1>:;
55   vara_6 = MAX_EXPR <varb_5, varz_2>;  */
56 
57 /* { dg-final { scan-tree-dump "if .*varz" "phiopt1"} } */
58 /* { dg-final { scan-tree-dump "vara.*MAX_EXPR" "phiopt1"} } */
59