| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-Ofast -fdump-tree-optimized-raw" } */ |
| 3 |
|
| 4 |
/* Don't expect any of these divisions to be extracted. */ |
| 5 |
double f (double x, int p) |
| 6 |
{ |
| 7 |
if (p > 0) |
| 8 |
{ |
| 9 |
return 1.0/(x * x); |
| 10 |
} |
| 11 |
|
| 12 |
if (p > -1) |
| 13 |
{ |
| 14 |
return x * x * x; |
| 15 |
} |
| 16 |
return 1.0 /(x); |
| 17 |
} |
| 18 |
|
| 19 |
/* Expect a reciprocal to be extracted here. */ |
| 20 |
double g (double *a, double x, double y) |
| 21 |
{ |
| 22 |
*a = 3 / y; |
| 23 |
double k = x / (y * y); |
| 24 |
|
| 25 |
if (y * y == 2.0) |
| 26 |
return k + 1 / y; |
| 27 |
else |
| 28 |
return k - 1 / y; |
| 29 |
} |
| 30 |
|
| 31 |
/* Expect 2 divisions in 'f' and 1 in 'g'. */ |
| 32 |
/* { dg-final { scan-tree-dump-times "rdiv_expr" 3 "optimized" } } */ |
| 33 |
/* Expect 3 multiplications in 'f' and 4 in 'g'. */ |
| 34 |
/* { dg-final { scan-tree-dump-times "mult_expr" 7 "optimized" } } */ |