public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Only use NO_REGS in cost calculation when !hard_regno_mode_ok for GENERAL_REGS and mode.
@ 2023-05-17  6:57 liuhongt
  2023-05-19 21:31 ` Jeff Law
  2023-05-25 14:29 ` Vladimir Makarov
  0 siblings, 2 replies; 4+ messages in thread
From: liuhongt @ 2023-05-17  6:57 UTC (permalink / raw)
  To: gcc-patches; +Cc: vmakarov, linkw, segher

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.
Kewen confirmed the patch fixed PR109858, I vefiried it also fixed PR109610.

Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}.
No big performance impact for SPEC2017 on icelake server.
Ok for trunk?

gcc/ChangeLog:

	* 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.
---
 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;
-- 
2.39.1.388.g2fc9e9ca3c


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Only use NO_REGS in cost calculation when !hard_regno_mode_ok for GENERAL_REGS and mode.
  2023-05-17  6:57 [PATCH] Only use NO_REGS in cost calculation when !hard_regno_mode_ok for GENERAL_REGS and mode liuhongt
@ 2023-05-19 21:31 ` Jeff Law
  2023-05-25 14:29 ` Vladimir Makarov
  1 sibling, 0 replies; 4+ messages in thread
From: Jeff Law @ 2023-05-19 21:31 UTC (permalink / raw)
  To: liuhongt, gcc-patches; +Cc: vmakarov, linkw, segher



On 5/17/23 00:57, liuhongt via Gcc-patches wrote:
> 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.
> Kewen confirmed the patch fixed PR109858, I vefiried it also fixed PR109610.
> 
> Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}.
> No big performance impact for SPEC2017 on icelake server.
> Ok for trunk?
> 
> gcc/ChangeLog:
> 
> 	* 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.
BTW, Vlad is on PTO right now.  I'm sure he'll handle this after he 
returns and starts digging out of all the stuff that's piled up.

jeff

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Only use NO_REGS in cost calculation when !hard_regno_mode_ok for GENERAL_REGS and mode.
  2023-05-17  6:57 [PATCH] Only use NO_REGS in cost calculation when !hard_regno_mode_ok for GENERAL_REGS and mode liuhongt
  2023-05-19 21:31 ` Jeff Law
@ 2023-05-25 14:29 ` Vladimir Makarov
  2023-05-25 15:37   ` Segher Boessenkool
  1 sibling, 1 reply; 4+ messages in thread
From: Vladimir Makarov @ 2023-05-25 14:29 UTC (permalink / raw)
  To: liuhongt, gcc-patches; +Cc: linkw, segher


On 5/17/23 02:57, liuhongt wrote:
> 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.
> Kewen confirmed the patch fixed PR109858, I vefiried it also fixed PR109610.
>
> Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}.
> No big performance impact for SPEC2017 on icelake server.
> Ok for trunk?
>
> gcc/ChangeLog:
>
> 	* 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.

Thank you for the patch.  It looks good for me.  It is ok to commit it 
into the trunk.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Only use NO_REGS in cost calculation when !hard_regno_mode_ok for GENERAL_REGS and mode.
  2023-05-25 14:29 ` Vladimir Makarov
@ 2023-05-25 15:37   ` Segher Boessenkool
  0 siblings, 0 replies; 4+ messages in thread
From: Segher Boessenkool @ 2023-05-25 15:37 UTC (permalink / raw)
  To: Vladimir Makarov; +Cc: liuhongt, gcc-patches, linkw

On Thu, May 25, 2023 at 10:29:47AM -0400, Vladimir Makarov wrote:
> 
> On 5/17/23 02:57, liuhongt wrote:
> >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.
> >Kewen confirmed the patch fixed PR109858, I vefiried it also fixed 
> >PR109610.
> >
> >Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}.
> >No big performance impact for SPEC2017 on icelake server.
> >Ok for trunk?
> >
> >gcc/ChangeLog:
> >
> >	* 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.
> 
> Thank you for the patch.  It looks good for me.  It is ok to commit it 
> into the trunk.

Thanks everyone involved for fixing this nasty regression!  Much
appreciated.


Segher

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-05-25 15:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-17  6:57 [PATCH] Only use NO_REGS in cost calculation when !hard_regno_mode_ok for GENERAL_REGS and mode liuhongt
2023-05-19 21:31 ` Jeff Law
2023-05-25 14:29 ` Vladimir Makarov
2023-05-25 15:37   ` Segher Boessenkool

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).