aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/pr96708-negative.c
blob: 91964d3b971dc52055db43f6a7fc6fdd257ac8e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* { dg-do run } */
/* { dg-options "-O -fdump-tree-optimized" } */

#include <stdbool.h>

bool __attribute__ ((noinline))
test1 (int a, int b)
{
    int tmp = (a < b) ? b : a;
    return tmp <= a;
}

bool __attribute__ ((noinline))
test2 (int a, int b)
{
    int tmp = (a < b) ? b : a;
    return tmp > a;
}

bool __attribute__ ((noinline))
test3 (int a, int b)
{
    int tmp = (a > b) ? b : a;
    return tmp >= a;
}

bool __attribute__ ((noinline))
test4 (int a, int b)
{
    int tmp = (a > b) ? b : a;
    return tmp < a;
}

int main()
{
    if (test1 (1, 2) || !test1 (2, 1) || 
        !test2 (1, 2) || test2 (2, 1) ||
        !test3 (1, 2) || test3 (2, 1) ||
        test4 (1, 2) || !test4 (2, 1)) {
        __builtin_abort();	
    }
    return 0;
}

/* { dg-final { scan-tree-dump-times "MAX_EXPR" 2 "optimized" } } */
/* { dg-final { scan-tree-dump-times "MIN_EXPR" 2 "optimized" } } */
/* { dg-final { scan-tree-dump-times "return 0;" 1 "optimized" } } */
/* { dg-final { scan-tree-dump-not { "return 1;" } "optimized" } } */