Debian Codegraph @

gcc/testsuite/gcc.dg/pr96708-negative.c

raw
1 /* { dg-do run } */
2 /* { dg-options "-O -fdump-tree-optimized" } */
3
4 #include <stdbool.h>
5
6 bool __attribute__ ((noinline))
7 test1 (int a, int b)
8 {
9 int tmp = (a < b) ? b : a;
10 return tmp <= a;
11 }
12
13 bool __attribute__ ((noinline))
14 test2 (int a, int b)
15 {
16 int tmp = (a < b) ? b : a;
17 return tmp > a;
18 }
19
20 bool __attribute__ ((noinline))
21 test3 (int a, int b)
22 {
23 int tmp = (a > b) ? b : a;
24 return tmp >= a;
25 }
26
27 bool __attribute__ ((noinline))
28 test4 (int a, int b)
29 {
30 int tmp = (a > b) ? b : a;
31 return tmp < a;
32 }
33
34 int main()
35 {
36 if (test1 (1, 2) || !test1 (2, 1) ||
37 !test2 (1, 2) || test2 (2, 1) ||
38 !test3 (1, 2) || test3 (2, 1) ||
39 test4 (1, 2) || !test4 (2, 1)) {
40 __builtin_abort();
41 }
42 return 0;
43 }
44
45 /* Even though test[1-4] originally has MIN/MAX, those can be optimized away
46 into just comparing a and b arguments. */
47 /* { dg-final { scan-tree-dump-times "return 0;" 1 "optimized" } } */
48 /* { dg-final { scan-tree-dump-not { "return 1;" } "optimized" } } */