1 /* { dg-do compile } */
2 /* { dg-options "-O2 -fdump-tree-optimized" } */
3
4 /* Should produce <=. */
test1(int a,int b)5 int test1 (int a, int b)
6 {
7 return (a < b || a == b);
8 }
9
10 /* Should produce <=. */
test2(int a,int b)11 int test2 (int a, int b)
12 {
13 int lt = a < b;
14 int eq = a == b;
15
16 return (lt || eq);
17 }
18
19 /* Should produce <= (just deleting redundant test). */
test3(int a,int b)20 int test3 (int a, int b)
21 {
22 int lt = a <= b;
23 int eq = a == b;
24
25 return (lt || eq);
26 }
27
28 /* Should produce <= (operands reversed to test the swap logic). */
test4(int a,int b)29 int test4 (int a, int b)
30 {
31 int lt = a < b;
32 int eq = b == a;
33
34 return (lt || eq);
35 }
36
37 /* Should produce constant 0. */
test5(int a,int b)38 int test5 (int a, int b)
39 {
40 int lt = a < b;
41 int eq = a == b;
42
43 return (lt && eq);
44 }
45
46 /* { dg-final { scan-tree-dump-times " <= " 4 "optimized" } } */
47 /* { dg-final { scan-tree-dump-times "return 0" 1 "optimized" } } */
48 /* { dg-final { scan-tree-dump-not " < " "optimized" } } */
49 /* { dg-final { scan-tree-dump-not " == " "optimized" } } */
50 /* { dg-final { cleanup-tree-dump "optimized" } } */
51