failed to reduce pow() with sqrt() with -ffast-math
Open
floating-point
llvm:optimizations
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
```c
#include
double foo(double x) {
return pow(sqrt(x), 4.0);
}
```
This can be reduced to x*x:
https://godbolt.org/z/a78oraYoP
It looks like the special case of pow(N, 2.0) is handled, but all higher exponents are missed. If the pow() is converted to powi() in IR, then there could be another transform to divide the exponent in half?
It also doesn't reduce when the sqrt() follows the pow(), so there's probably a missing pow/sqrt canonicalization:
https://godbolt.org/z/4e1Phv8Y7
Contributor guide
Assessment
This issue has not been assessed yet.