Issue 180948
Summary failed to reduce pow() with sqrt() input with -ffast-math
Labels new issue
Assignees
Reporter rotateright
    ```
#include <math.h>

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
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to