This patch transforms the following POW calls to equivalent LDEXP calls, as
discussed in PR57492:

powi (2.0, i) -> ldexp (1.0, i)

a * powi (2.0, i) -> ldexp (a, i)

2.0 * powi (2.0, i) -> ldexp (1.0, i + 1)

pow (powof2, i) -> ldexp (1.0, i * log2 (powof2))

powof2 * pow (2, i) -> ldexp (1.0, i + log2 (powof2))

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/pipermail/gcc-patches/2024-September/664160.html

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.
OK for mainline?

Signed-off-by: Soumya AR <soum...@nvidia.com>

gcc/ChangeLog:
        PR target/57492
        * match.pd: Added patterns to fold certain calls to pow to ldexp.

gcc/testsuite/ChangeLog:
        PR target/57492
        * gcc.dg/tree-ssa/pow-to-ldexp.c: New test.

Attachment: 0001-Match-Fold-pow-calls-to-ldexp-when-possible-PR57492.patch
Description: 0001-Match-Fold-pow-calls-to-ldexp-when-possible-PR57492.patch

Reply via email to