summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/fold-cond-1.c
blob: b6e8a0ec3552226935d7b2adb3db0b2b1665919a (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
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-original" } */

_Bool test1(int a, int b)
{
  return a ? b : 0;
}

_Bool test2(int c, int d)
{
  return c ? d : 1;
}

_Bool test3(int e, int f)
{
  return e ? 0 : f;
}

_Bool test4(int g, int h)
{
  return g ? 1 : h;
}

/* { dg-final { scan-tree-dump-times "a != 0 \&\& b != 0" 1 "original" } } */
/* { dg-final { scan-tree-dump-times "c == 0 \\|\\| d != 0" 1 "original" } } */
/* { dg-final { scan-tree-dump-times "e == 0 \&\& f != 0" 1 "original" } } */
/* { dg-final { scan-tree-dump-times "g == 0 \\? h != 0 : 1" 0 "original" } } */
/* { dg-final { scan-tree-dump-times "g != 0 \\? 1 : h != 0" 0 "original" } } */
/* { dg-final { cleanup-tree-dump "original" } } */