| 1 |
/* { dg-do compile } */ |
| 2 |
/* Disable phiopt as that will optimize away the `?:`, |
| 3 |
want to test simplify-rtx */ |
| 4 |
/* { dg-options "-O2 -fno-ssa-phiopt" } */ |
| 5 |
|
| 6 |
/* PR rtl-optimization/58195 */ |
| 7 |
|
| 8 |
int a2(int input) |
| 9 |
{ |
| 10 |
if (input == 0) |
| 11 |
return 0; |
| 12 |
return -input; |
| 13 |
} |
| 14 |
int a1(int input) |
| 15 |
{ |
| 16 |
int t = -input; |
| 17 |
return input == 0 ? 0 : t; |
| 18 |
} |
| 19 |
|
| 20 |
int a(int input) |
| 21 |
{ |
| 22 |
int value = 0; |
| 23 |
for(int n = input; n != 0; ++n) |
| 24 |
++value; |
| 25 |
return value; |
| 26 |
} |
| 27 |
|
| 28 |
/* There should be no comparison against 0 here, */ |
| 29 |
/* { dg-final { scan-assembler-not "cmp\t" } } */ |
| 30 |
/* { dg-final { scan-assembler "\tneg\t" } } */ |
| 31 |
|