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>