Match: Fold pow calls to ldexp when possible [PR57492]
This patch transforms the following POW calls to equivalent LDEXP calls, as
discussed in PR57492:
powi (powof2, i) -> ldexp (1.0, i * log2 (powof2))
powof2 * ldexp (x, i) -> ldexp (x, i + log2 (powof2))
a * ldexp(1., i) -> ldexp (a, i)
This is especially helpful for SVE architectures as LDEXP calls can be
implemented using the FSCALE instruction, as seen in the following patch:
https://gcc.gnu.org/g:
9b2915d95d855333d4d8f66b71a75f653ee0d076
SPEC2017 was run with this patch, while there are no noticeable improvements,
there are no non-noise regressions either.
The patch was bootstrapped and regtested on aarch64-linux-gnu, no regression.
Signed-off-by: Soumya AR <soumyaa@nvidia.com>
gcc/ChangeLog:
PR target/57492
* match.pd: Added patterns to fold calls to pow to ldexp and optimize
specific ldexp calls.
gcc/testsuite/ChangeLog:
PR target/57492
* gcc.dg/tree-ssa/ldexp.c: New test.
* gcc.dg/tree-ssa/pow-to-ldexp.c: New test.