| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-O1 -fdump-tree-fre3 -fdump-tree-phiopt1 -fdump-tree-optimized" } */ |
| 3 |
|
| 4 |
[[gnu::const]] |
| 5 |
int constcall(int); |
| 6 |
|
| 7 |
int fdiv(int a, int b) |
| 8 |
{ |
| 9 |
int c = b/a; |
| 10 |
int t = constcall(c); |
| 11 |
int d; |
| 12 |
if (a == 1) d = b; else d = c; |
| 13 |
return constcall(d) + t; |
| 14 |
} |
| 15 |
int fmult(int a, int b) |
| 16 |
{ |
| 17 |
int c = b*a; |
| 18 |
int t = constcall(c); |
| 19 |
int d; |
| 20 |
if (a == 1) d = b; else d = c; |
| 21 |
return constcall(d) + t; |
| 22 |
} |
| 23 |
int fand(int a, int b) |
| 24 |
{ |
| 25 |
int c = b&a; |
| 26 |
int t = constcall(c); |
| 27 |
int d; |
| 28 |
if (a == -1) d = b; else d = c; |
| 29 |
return constcall(d) + t; |
| 30 |
} |
| 31 |
|
| 32 |
/* Should be able to optimize away the if statements in phiopt1. */ |
| 33 |
/* { dg-final { scan-tree-dump-not "if " "phiopt1" } } */ |
| 34 |
/* fre3 should be optimize each function to just `return constcall(a OP b) * 2;`. */ |
| 35 |
/* { dg-final { scan-tree-dump-times "constcall " 3 "fre3" } } */ |
| 36 |
/* { dg-final { scan-tree-dump-times "constcall " 3 "optimized" } } */ |