aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/pr114090.c
blob: dcc2f8bb3721ea4660181f8cb330f4a6f2f3cbe9 (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
/* PR tree-optimization/114090 */
/* { dg-do run } */
/* { dg-options "-O2 -fwrapv" } */

__attribute__((noipa)) int
foo (int x)
{
  int w = (x >= 0 ? x : 0);
  int y = -x;
  int z = (y >= 0 ? y : 0);
  return w + z;
}

__attribute__((noipa)) int
bar (int x)
{
  int w = (x >= 0 ? x : 0);
  int z = (x <= 0 ? -x : 0);
  return w + z;
}

__attribute__((noipa)) int
baz (int x)
{
  return x <= 0 ? -x : 0;
}

int
main ()
{
  int v = -__INT_MAX__ - 1;
  if (foo (v) != 0)
    __builtin_abort ();
  if (bar (v) != v)
    __builtin_abort ();
  if (baz (v) != v)
    __builtin_abort ();
}