public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
*  [PATCH PR95696] regrename creates overlapping register allocations for vliw
@ 2020-07-16 16:18 zhongyunde
  2020-07-20  0:59 ` Zhongyunde
  0 siblings, 1 reply; 5+ messages in thread
From: zhongyunde @ 2020-07-16 16:18 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1715 bytes --]

hi,   Insometarget,itislimitedtoissuetwoinsnstogetherwithchangethesameregister,so Imakeapatchtoextendtheliverangeuntiltheendofvliwtoavoidit.(Theinsn73startwithinsn:TI,soitwillbeissuedtogetherwithothersinsnsuntilanewinsnstartwithinsn:TI,suchasinsn71)TheregrenamecanknownthemodeV2VFininsn73needtwosuccessiveregisters,i.e.v2andv3,hereisdumpsnippetbeforetheregrename.(insn:TI7376714(set(reg/v:V2VF37v2[orig:180_62][180])(unspec:V2VF[(reg/v:VHF43v8[orig:210Dest_value][210])(reg/v:VHF43v8[orig:210Dest_value][210])]UNSPEC_HFSQMAG_32X32))"../test_modify.c":57710{hfsqmag_v2vf}(expr_list:REG_DEAD(reg/v:VHF43v8[orig:210Dest_value][210])(expr_list:REG_UNUSED(reg:VHF38v3)(expr_list:REG_STAGE(const_int2[0x2])(expr_list:REG_CYCLE(const_int2[0x2])(expr_list:REG_UNITS(const_int256[0x100])(nil)))))))(insn71732434(set(reg:VHF43v8[orig:265MEM[(constvfloat32x16*)Src_base_134]][265])(mem:VHF(reg/v/f:DI13a13[orig:207Src_base][207])[1MEM[(constvfloat32x16*)Src_base_134]+0S64A512]))"../test_modify.c":56450{movvhf_internal}(expr_list:REG_STAGE(const_int1[0x1])(expr_list:REG_CYCLE(const_int2[0x2])(nil))))Then,intheregrename,theinsn71willbetransformedintofollowingcodewithregisterv3,sothereisanconflictbetweeninsn73andinsn71,asbothofthemsetthev3register.Registerv2(2):73[SVEC_REGS]Registerv8(1):71[VEC_ALL_REGS]....(insn71732434(set(reg:VHF38v3[orig:265MEM[(constvfloat32x16*)Src_base_134]][265])(mem:VHF(reg/v/f:DI13a13[orig:207Src_base][207])[1MEM[(constvfloat32x16*)Src_base_134]+0S64A512]))"../test_modify.c":56450{movvhf_internal}(expr_list:REG_STAGE(const_int1[0x1]) (expr_list:REG_CYCLE(const_int2[0x2]) 随心邮-在微信里收发邮件,及时省电又安心

[-- Attachment #2: PR95696.patch --]
[-- Type: application/octet-stream, Size: 2658 bytes --]

diff --git a/gcc/regrename.c b/gcc/regrename.c
index c38173a77..e54794413 100644
--- a/gcc/regrename.c
+++ b/gcc/regrename.c
@@ -1614,12 +1614,26 @@ record_out_operands (rtx_insn *insn, bool earlyclobber, insn_rr_info *insn_info)
   cur_operand = NULL;
 }
 
+/* Get the first real insn of next vliw in current BB.  */
+static rtx_insn *
+get_next_vliw_first_insn (rtx_insn *cur_insn, basic_block bb)
+{
+  rtx_insn *insn = next_real_insn (cur_insn);
+
+  for (; insn && insn != BB_END (bb); insn = next_real_insn (insn))
+    if (GET_MODE (insn) == TImode)
+      return insn;
+
+  return cur_insn;
+}
+
 /* Build def/use chain.  */
 
 static bool
 build_def_use (basic_block bb)
 {
   rtx_insn *insn;
+  rtx_insn *vliw_start_insn = NULL;
   unsigned HOST_WIDE_INT untracked_operands;
 
   fail_current_block = false;
@@ -1663,6 +1677,9 @@ build_def_use (basic_block bb)
 	     to be marked unrenamable or even cause us to abort the entire
 	     basic block.  */
 
+	  if (GET_MODE (insn) == TImode)
+	    vliw_start_insn = insn;
+
 	  extract_constrain_insn (insn);
 	  preprocess_constraints (insn);
 	  const operand_alternative *op_alt = which_op_alt ();
@@ -1858,17 +1875,26 @@ build_def_use (basic_block bb)
 	      scan_rtx (insn, &XEXP (note, 0), ALL_REGS, mark_access,
 			OP_INOUT);
 
-	  /* Step 7: Close chains for registers that were never
-	     really used here.  */
-	  for (note = REG_NOTES (insn); note; note = XEXP (note, 1))
-	    if (REG_NOTE_KIND (note) == REG_UNUSED)
-	      {
-		remove_from_hard_reg_set (&live_hard_regs,
-					  GET_MODE (XEXP (note, 0)),
-					  REGNO (XEXP (note, 0)));
-		scan_rtx (insn, &XEXP (note, 0), NO_REGS, terminate_dead,
-			  OP_IN);
-	      }
+	  /* Step 7: Close chains for registers that were never
+	     really used delayed at the end of vliw.  */
+	  if (vliw_start_insn
+	      && next_real_insn (insn) == get_next_vliw_first_insn (insn, bb))
+	    {
+	      rtx_insn *member;
+
+	      for (member = vliw_start_insn;
+	           member != next_active_insn (insn);
+	           member = next_active_insn (member))
+	        for (note = REG_NOTES (member); note; note = XEXP (note, 1))
+	          if (REG_NOTE_KIND (note) == REG_UNUSED)
+	            {
+	              remove_from_hard_reg_set (&live_hard_regs,
+	                                        GET_MODE (XEXP (note, 0)),
+	                                        REGNO (XEXP (note, 0)));
+	              scan_rtx (member, &XEXP (note, 0), NO_REGS, terminate_dead,
+	                        OP_IN);
+	            }
+	    }
 
 	  /* Step 8: Kill the chains involving register restores.  Those
 	     should restore _that_ register.  */

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

end of thread, other threads:[~2020-07-21 16:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-16 16:18 [PATCH PR95696] regrename creates overlapping register allocations for vliw zhongyunde
2020-07-20  0:59 ` Zhongyunde
2020-07-20 16:05   ` Richard Sandiford
2020-07-21  7:20     ` 答复: " Zhongyunde
2020-07-21 16:12       ` Richard Sandiford

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