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>