aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/tree-ssa/pr96928-1.c
blob: 9e505ac9900b8d45d2c6533ccbfc3b7a3b141d44 (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
49
50
51
/* PR tree-optimization/96928 */
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-phiopt2 -fdump-tree-optimized" } */
/* { dg-final { scan-tree-dump-times " = a_\[0-9]*\\\(D\\\) >> " 5 "phiopt2" } } */
/* The following check is done at optimized because a ^ (~b) is rewritten as ~(a^b)
   and in the case of match.pd optimizing these ?:, the ~ is moved out already
   by the time we get to phiopt2. */
/* { dg-final { scan-tree-dump-times "c_\[0-9]*\\\(D\\\) \\\^" 1 "optimized" } } */
/* { dg-final { scan-tree-dump-times " = ~" 1 "optimized" } } */
/* { dg-final { scan-tree-dump-times " = \[abc_0-9\\\(\\\)D]* \\\^ " 5 "phiopt2" } } */
/* { dg-final { scan-tree-dump-not "a < 0" "phiopt2" } } */

int
foo (int a)
{
  if (a < 0)
    return ~a;
  return a;
}

int
bar (int a, int b)
{
  if (a < 0)
    return ~b;
  return b;
}

unsigned
baz (int a, unsigned int b)
{
  if (a < 0)
    return ~b;
  return b;
}

unsigned
qux (int a, unsigned int c)
{
  if (a >= 0)
    return ~c;
  return c;
}

int
corge (int a, int b)
{
  if (a >= 0)
    return b;
  return ~b;
}