| 1 |
/* PR tree-optimization/114090 */ |
| 2 |
/* { dg-do run } */ |
| 3 |
/* { dg-options "-O2 -fwrapv" } */ |
| 4 |
|
| 5 |
__attribute__((noipa)) int |
| 6 |
foo (int x) |
| 7 |
{ |
| 8 |
int w = (x >= 0 ? x : 0); |
| 9 |
int y = -x; |
| 10 |
int z = (y >= 0 ? y : 0); |
| 11 |
return w + z; |
| 12 |
} |
| 13 |
|
| 14 |
__attribute__((noipa)) int |
| 15 |
bar (int x) |
| 16 |
{ |
| 17 |
int w = (x >= 0 ? x : 0); |
| 18 |
int z = (x <= 0 ? -x : 0); |
| 19 |
return w + z; |
| 20 |
} |
| 21 |
|
| 22 |
__attribute__((noipa)) int |
| 23 |
baz (int x) |
| 24 |
{ |
| 25 |
return x <= 0 ? -x : 0; |
| 26 |
} |
| 27 |
|
| 28 |
int |
| 29 |
main () |
| 30 |
{ |
| 31 |
int v = -__INT_MAX__ - 1; |
| 32 |
if (foo (v) != 0) |
| 33 |
__builtin_abort (); |
| 34 |
if (bar (v) != v) |
| 35 |
__builtin_abort (); |
| 36 |
if (baz (v) != v) |
| 37 |
__builtin_abort (); |
| 38 |
} |