]> git.ipfire.org Git - thirdparty/gcc.git/commit
expand: Use rtx_cost directly instead of gen_move_insn for canonicalize_comparison.
authorAndrew Pinski <quic_apinski@quicinc.com>
Tue, 20 May 2025 21:48:58 +0000 (14:48 -0700)
committerAndrew Pinski <quic_apinski@quicinc.com>
Thu, 22 May 2025 13:09:46 +0000 (06:09 -0700)
commit21a487046f4acda0d7d3aaed08a99501bd0430d3
tree53d7ab45dfc7a91e8ef2cf32e4f9cb10caa76a2d
parent0faa31da113768a626daa294e840ff1b17499ebf
expand: Use rtx_cost directly instead of gen_move_insn for canonicalize_comparison.

This is the first part in fixing PR target/120372.
The current code for canonicalize_comparison, uses gen_move_insn and rtx_cost to find
out the cost of generating a constant. This is ok in most cases except sometimes
the comparison instruction can handle different constants than a simple set
intruction can do. This changes to use rtx_cost directly with the outer being COMPARE
just like how prepare_cmp_insn handles that.

Note this is also a small speedup and small memory improvement because we are not creating
a move for the constant any more. Since we are not creating a psedu-register any more, this
also removes the check on that.

Also adds a dump so we can see why one choice was chosen over the other.

Build and tested for aarch64-linux-gnu.

gcc/ChangeLog:

* expmed.cc (canonicalize_comparison): Use rtx_cost directly
instead of gen_move_insn. Print out the choice if dump is enabled.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
gcc/expmed.cc