This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [please test] RTL sharing verifier


Jan Hubicka <jh@suse.cz> wrote:
> as mentioned in previous mail, I would like to get the RTL sharing
> verifier enabled in stage1 now.  I am however aware that this is likely
> going to find many positives, probably more than I can deal with myself
> in resonable time.  I am attaching my current patch I know to work on
> i686 to ask everyone who wants to do little RTL debugging on his
> favorite target to try it out and let me know how it works and if
> possible also send fixes.

I've tried to build several cross targets with your RTL sharing
verifier patch.  arm-eabi can be built with no additional changes.
mips-elf requires an extra change below of emit_delay_sequence.
For sh*-elf and sh4-*-linux-gnu, I needed some changes for sh.md
and the attached extra changes against generic files, though I
could be totally wrong about them.  On SH, a change for gen_insn
was needed to avoid sharing operands[1] of

(define_insn "ashlsi_c"
  [(set (match_operand:SI 0 "arith_reg_dest" "=r")
	(ashift:SI (match_operand:SI 1 "arith_reg_operand" "0") (const_int 1)))
   (set (reg:SI T_REG)
	(lt:SI (match_dup 1) (const_int 0)))]
   ...

with two set insns, for example.  A similar change for gen_expand
was needed to avoid sharing operands[1] of

(define_expand "movsi_const"
  [(set (match_operand:SI 0 "arith_reg_operand" "=r")
	(const:SI (sign_extend:SI
		   (truncate:HI
		    (ashiftrt:SI
		     (match_operand:DI 1 "immediate_operand" "s")
		     (const_int 16))))))
   (set (match_dup 0)
	(ior:SI (ashift:SI (match_dup 0) (const_int 16))
		(const:SI
		  (zero_extend:SI
 		   (truncate:HI (match_dup 1))))))]
   ...

with two set insns.  Mips and SH require a copy_rtx in reorg.c/
emit_delay_sequence to avoid sharing the rtl for the branch
slot insn.

Regards,
	kaz
--
diff -uprN MISC/trunk/gcc/genemit.c TEST/trunk/gcc/genemit.c
--- MISC/trunk/gcc/genemit.c	2006-03-30 22:21:21.000000000 +0900
+++ TEST/trunk/gcc/genemit.c	2006-11-10 18:07:56.000000000 +0900
@@ -428,15 +428,18 @@ gen_insn (rtx insn, int lineno)
     }
   else
     {
+      char *used = XCNEWVEC (char, operands);
+
       printf ("  return gen_rtx_PARALLEL (VOIDmode, gen_rtvec (%d",
 	      XVECLEN (insn, 1));
 
       for (i = 0; i < XVECLEN (insn, 1); i++)
 	{
 	  printf (",\n\t\t");
-	  gen_exp (XVECEXP (insn, 1, i), DEFINE_INSN, NULL);
+	  gen_exp (XVECEXP (insn, 1, i), DEFINE_INSN, used);
 	}
       printf ("));\n}\n\n");
+      free (used);
     }
 }
 
@@ -447,6 +450,7 @@ gen_expand (rtx expand)
 {
   int operands;
   int i;
+  char *used;
 
   if (strlen (XSTR (expand, 0)) == 0)
     fatal ("define_expand lacks a name");
@@ -530,6 +534,8 @@ gen_expand (rtx expand)
      Use emit_insn to add them to the sequence being accumulated.
      But don't do this if the user's code has set `no_more' nonzero.  */
 
+  used = XCNEWVEC (char, operands);
+
   for (i = 0; i < XVECLEN (expand, 1); i++)
     {
       rtx next = XVECEXP (expand, 1, i);
@@ -560,13 +566,15 @@ gen_expand (rtx expand)
 	printf ("  emit (");
       else
 	printf ("  emit_insn (");
-      gen_exp (next, DEFINE_EXPAND, NULL);
+      gen_exp (next, DEFINE_EXPAND, used);
       printf (");\n");
       if (GET_CODE (next) == SET && GET_CODE (SET_DEST (next)) == PC
 	  && GET_CODE (SET_SRC (next)) == LABEL_REF)
 	printf ("  emit_barrier ();");
     }
 
+  free (used);
+
   /* Call `get_insns' to extract the list of all the
      insns emitted within this gen_... function.  */
 
diff -uprN MISC/trunk/gcc/reorg.c TEST/trunk/gcc/reorg.c
--- MISC/trunk/gcc/reorg.c	2006-08-17 07:47:33.000000000 +0900
+++ TEST/trunk/gcc/reorg.c	2006-11-10 10:26:19.000000000 +0900
@@ -513,7 +513,7 @@ emit_delay_sequence (rtx insn, rtx list,
 
   for (li = list; li; li = XEXP (li, 1), i++)
     {
-      rtx tem = XEXP (li, 0);
+      rtx tem = copy_rtx (XEXP (li, 0));
       rtx note, next;
 
       /* Show that this copy of the insn isn't deleted.  */
diff -uprN MISC/trunk/gcc/config/sh/sh.md TEST/trunk/gcc/config/sh/sh.md
--- MISC/trunk/gcc/config/sh/sh.md	2006-11-05 10:02:45.000000000 +0900
+++ TEST/trunk/gcc/config/sh/sh.md	2006-11-10 17:25:36.000000000 +0900
@@ -3752,7 +3752,7 @@ label:
   "
 {
   emit_insn (gen_ashlsi_c (operands[0], operands[1]));
-  emit_insn (gen_mov_neg_si_t (operands[0]));
+  emit_insn (gen_mov_neg_si_t (copy_rtx (operands[0])));
   DONE;
 }")
 
@@ -5113,7 +5113,7 @@ label:
 {
   rtx insn = emit_insn (gen_movsi_const (operands[0], operands[1]));
 
-  REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_EQUAL, operands[1],
+  REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_EQUAL, copy_rtx (operands[1]),
 					REG_NOTES (insn));
 
   DONE;
@@ -5497,7 +5497,7 @@ label:
   else
     insn = emit_insn (gen_movdi_const_32bit (operands[0], operands[1]));
 
-  REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_EQUAL, operands[1],
+  REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_EQUAL, copy_rtx (operands[1]),
 					REG_NOTES (insn));
 
   DONE;
@@ -7390,7 +7390,7 @@ label:
     emit_insn (gen_sym_label2reg (operands[2], operands[0], lab));
   else
     emit_insn (gen_symPLT_label2reg (operands[2], operands[0], lab));
-  emit_call_insn (gen_calli_pcrel (operands[2], operands[1], lab));
+  emit_call_insn (gen_calli_pcrel (operands[2], operands[1], copy_rtx (lab)));
   DONE;
 }"
   [(set_attr "type" "call")
@@ -7494,7 +7494,7 @@ label:
   else
     emit_insn (gen_symPLT_label2reg (operands[3], operands[1], lab));
   emit_call_insn (gen_call_valuei_pcrel (operands[0], operands[3],
-					 operands[2], lab));
+					 operands[2], copy_rtx (lab)));
   DONE;
 }"
   [(set_attr "type" "call")
@@ -7875,7 +7875,7 @@ label:
 
   emit_insn (gen_sym_label2reg (operands[2], operands[0], lab));
   call_insn = emit_call_insn (gen_sibcalli_pcrel (operands[2], operands[1],
-						  lab));
+						  copy_rtx (lab)));
   SIBLING_CALL_P (call_insn) = 1;
   DONE;
 }"
@@ -8313,12 +8313,12 @@ label:
       if (Pmode == SImode)
 	{
 	  emit_insn (gen_movsi_const (pic, operands[1]));
-	  emit_insn (gen_ptrel_si (tr, pic, lab));
+	  emit_insn (gen_ptrel_si (tr, pic, copy_rtx (lab)));
 	}
       else
 	{
 	  emit_insn (gen_movdi_const (pic, operands[1]));
-	  emit_insn (gen_ptrel_di (tr, pic, lab));
+	  emit_insn (gen_ptrel_di (tr, pic, copy_rtx (lab)));
 	}
 
       insn = emit_move_insn (operands[0], tr);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]