| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-O2 -fdump-tree-phiopt1-details -fdump-tree-optimized" } */ |
| 3 |
|
| 4 |
/* PR tree-optimization/112418 */ |
| 5 |
|
| 6 |
int f(int a, int b, int d) |
| 7 |
{ |
| 8 |
int c; |
| 9 |
if (a < 0) |
| 10 |
{ |
| 11 |
a = -a; |
| 12 |
c = d > 0 ? d : -d; |
| 13 |
} |
| 14 |
else |
| 15 |
{ |
| 16 |
a = a; |
| 17 |
c = d > 0 ? d : -d; |
| 18 |
} |
| 19 |
return a + c; |
| 20 |
} |
| 21 |
|
| 22 |
/* ABS <d> should be able to pull out of the if statement early on in phiopt1. */ |
| 23 |
/* { dg-final { scan-tree-dump "changed to factor operation out from " "phiopt1" } } */ |
| 24 |
/* { dg-final { scan-tree-dump-not "if " "phiopt1" } } */ |
| 25 |
/* { dg-final { scan-tree-dump-times "ABS_EXPR " 2 "phiopt1" } } */ |
| 26 |
/* { dg-final { scan-tree-dump-not "if " "optimized" } } */ |
| 27 |
/* { dg-final { scan-tree-dump-times "ABS_EXPR " 2 "optimized" } } */ |