public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-1252] Only use NO_REGS in cost calculation when !hard_regno_mode_ok for GENERAL_REGS and mode.
@ 2023-05-26  1:46 hongtao Liu
  0 siblings, 0 replies; only message in thread
From: hongtao Liu @ 2023-05-26  1:46 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:4fb66b2329319e9b47e89200d613b6f741a114fc

commit r14-1252-g4fb66b2329319e9b47e89200d613b6f741a114fc
Author: liuhongt <hongtao.liu@intel.com>
Date:   Tue May 16 10:36:16 2023 +0800

    Only use NO_REGS in cost calculation when !hard_regno_mode_ok for GENERAL_REGS and mode.
    
    r14-172-g0368d169492017 replaces GENERAL_REGS with NO_REGS in cost
    calculation when the preferred register class are not known yet.
    It regressed powerpc PR109610 and PR109858, it looks too aggressive to use
    NO_REGS when mode can be allocated with GENERAL_REGS.
    The patch takes a step back, still use GENERAL_REGS when
    hard_regno_mode_ok for mode and GENERAL_REGS, otherwise uses NO_REGS.
    
    gcc/ChangeLog:
    
            PR target/109610
            PR target/109858
            * ira-costs.cc (scan_one_insn): Only use NO_REGS in cost
            calculation when !hard_regno_mode_ok for GENERAL_REGS and
            mode, otherwise still use GENERAL_REGS.

Diff:
---
 gcc/ira-costs.cc | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/gcc/ira-costs.cc b/gcc/ira-costs.cc
index d2a801ab9b0..ae8304ff938 100644
--- a/gcc/ira-costs.cc
+++ b/gcc/ira-costs.cc
@@ -1572,12 +1572,16 @@ scan_one_insn (rtx_insn *insn)
       && (! ira_use_lra_p || ! pic_offset_table_rtx
 	  || ! contains_symbol_ref_p (XEXP (note, 0))))
     {
-      /* Costs for NO_REGS are used in cost calculation on the
-	 1st pass when the preferred register classes are not
-	 known yet.  In this case we take the best scenario.  */
-      enum reg_class cl = NO_REGS;
+      enum reg_class cl = GENERAL_REGS;
       rtx reg = SET_DEST (set);
       int num = COST_INDEX (REGNO (reg));
+      /* Costs for NO_REGS are used in cost calculation on the
+	 1st pass when the preferred register classes are not
+	 known yet.  In this case we take the best scenario when
+	 mode can't be put into GENERAL_REGS.  */
+      if (!targetm.hard_regno_mode_ok (ira_class_hard_regs[cl][0],
+				       GET_MODE (reg)))
+	cl = NO_REGS;
 
       COSTS (costs, num)->mem_cost
 	-= ira_memory_move_cost[GET_MODE (reg)][cl][1] * frequency;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-05-26  1:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-26  1:46 [gcc r14-1252] Only use NO_REGS in cost calculation when !hard_regno_mode_ok for GENERAL_REGS and mode hongtao Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).