]> git.ipfire.org Git - thirdparty/gcc.git/commit
aarch64: Improve rtx_cost for constants in COMPARE [PR120372]
authorAndrew Pinski <quic_apinski@quicinc.com>
Tue, 20 May 2025 22:10:15 +0000 (15:10 -0700)
committerAndrew Pinski <quic_apinski@quicinc.com>
Thu, 22 May 2025 13:09:46 +0000 (06:09 -0700)
commitbb7b6d9ad7f89ebc68c9d1eff16bec95f6e81cd9
tree807c1e67ee2944be1b436d063012a64e42f529dd
parent21a487046f4acda0d7d3aaed08a99501bd0430d3
aarch64: Improve rtx_cost for constants in COMPARE [PR120372]

The middle-end uses rtx_cost on constants with the outer of being COMPARE
to find out the cost of a constant formation for a comparison instruction.
So for aarch64 backend, we would just return the cost of constant formation
in general. We can improve this by seeing if the outer is COMPARE and if
the constant fits the constraints of the cmp instruction just set the costs
to being one instruction.

Built and tested for aarch64-linux-gnu.

PR target/120372

gcc/ChangeLog:

* config/aarch64/aarch64.cc (aarch64_rtx_costs <case CONST_INSN>): Handle
if outer is COMPARE and the constant can be handled by the cmp instruction.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/imm_choice_comparison-2.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
gcc/config/aarch64/aarch64.cc
gcc/testsuite/gcc.target/aarch64/imm_choice_comparison-2.c [new file with mode: 0644]