[Bug middle-end/120372] canonicalize_comparison uses gen_move_insn to calcualate the cost of the constant formation
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120372 Andrew Pinski changed: What|Removed |Added Status|ASSIGNED|RESOLVED Resolution|--- |FIXED Target Milestone|--- |16.0 --- Comment #6 from Andrew Pinski --- Fixed.
[Bug middle-end/120372] canonicalize_comparison uses gen_move_insn to calcualate the cost of the constant formation
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120372 --- Comment #5 from GCC Commits --- The trunk branch has been updated by Andrew Pinski : https://gcc.gnu.org/g:bb7b6d9ad7f89ebc68c9d1eff16bec95f6e81cd9 commit r16-823-gbb7b6d9ad7f89ebc68c9d1eff16bec95f6e81cd9 Author: Andrew Pinski Date: Tue May 20 15:10:15 2025 -0700 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 ): 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
[Bug middle-end/120372] canonicalize_comparison uses gen_move_insn to calcualate the cost of the constant formation
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120372 --- Comment #4 from GCC Commits --- The trunk branch has been updated by Andrew Pinski : https://gcc.gnu.org/g:21a487046f4acda0d7d3aaed08a99501bd0430d3 commit r16-822-g21a487046f4acda0d7d3aaed08a99501bd0430d3 Author: Andrew Pinski Date: Tue May 20 14:48:58 2025 -0700 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
[Bug middle-end/120372] canonicalize_comparison uses gen_move_insn to calcualate the cost of the constant formation
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120372 --- Comment #3 from Andrew Pinski --- Patch posted: https://gcc.gnu.org/pipermail/gcc-patches/2025-May/684328.html https://gcc.gnu.org/pipermail/gcc-patches/2025-May/684329.html (with extra comments added compared to the patch attached here and split into 2).
[Bug middle-end/120372] canonicalize_comparison uses gen_move_insn to calcualate the cost of the constant formation
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120372 --- Comment #2 from Andrew Pinski --- Created attachment 61484 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=61484&action=edit Fix for both the middle-end part and the backend part
[Bug middle-end/120372] canonicalize_comparison uses gen_move_insn to calcualate the cost of the constant formation
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120372 Andrew Pinski changed: What|Removed |Added Ever confirmed|0 |1 Last reconfirmed||2025-05-20 Status|UNCONFIRMED |ASSIGNED --- Comment #1 from Andrew Pinski --- .
