[patch][i386] Remove code executed only if reload_in_progress (i.e. never)

Steven Bosscher stevenb.gcc@gmail.com
Wed Jan 8 21:52:00 GMT 2014


Hello Uros, and everyone else,

Now that LRA is always used for the i386 targets, reload_in_progress
is never set so all code conditional on it is now dead. The attached
patch removes this code.

Sadly I'm having difficulty testing the patch because I have no access
to a suitable x86_64 or ix86 box :-) I'll try to test the patch on a
compile farm machine, but I'm already posting the patch to hear if
this is still OK for this late stage of the development cycle. It's
not as if we're going to go back to reload so the code really is dead
AFAICT, but it's obviously not a bug fix.

Ciao!
Steven
-------------- next part --------------

	* i386/i386.c (legitimize_pic_address): Remove never-executed code,
	reload_in_progress is never set if LRA is used.
	(legitimize_tls_address): Likewise.
	(ix86_expand_move): Likewise.
	(ix86_expand_binary_operator): Likewise.
	(ix86_expand_unary_operator): Likewise.
	* i386/predicates.md (index_register_operand): Likewise.

Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c	(revision 206444)
+++ config/i386/i386.c	(working copy)
@@ -13013,11 +13013,7 @@ legitimize_pic_address (rtx orig, rtx reg)
 	   && ix86_cmodel != CM_SMALL_PIC && gotoff_operand (addr, Pmode))
     {
       rtx tmpreg;
-      /* This symbol may be referenced via a displacement from the PIC
-	 base address (@GOTOFF).  */
 
-      if (reload_in_progress)
-	df_set_regs_ever_live (PIC_OFFSET_TABLE_REGNUM, true);
       if (GET_CODE (addr) == CONST)
 	addr = XEXP (addr, 0);
       if (GET_CODE (addr) == PLUS)
@@ -13046,11 +13042,6 @@ legitimize_pic_address (rtx orig, rtx reg)
     }
   else if (!TARGET_64BIT && !TARGET_PECOFF && gotoff_operand (addr, Pmode))
     {
-      /* This symbol may be referenced via a displacement from the PIC
-	 base address (@GOTOFF).  */
-
-      if (reload_in_progress)
-	df_set_regs_ever_live (PIC_OFFSET_TABLE_REGNUM, true);
       if (GET_CODE (addr) == CONST)
 	addr = XEXP (addr, 0);
       if (GET_CODE (addr) == PLUS)
@@ -13108,11 +13099,6 @@ legitimize_pic_address (rtx orig, rtx reg)
 	}
       else
 	{
-	  /* This symbol must be referenced via a load from the
-	     Global Offset Table (@GOT).  */
-
-	  if (reload_in_progress)
-	    df_set_regs_ever_live (PIC_OFFSET_TABLE_REGNUM, true);
 	  new_rtx = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, addr), UNSPEC_GOT);
 	  new_rtx = gen_rtx_CONST (Pmode, new_rtx);
 	  if (TARGET_64BIT)
@@ -13164,8 +13150,6 @@ legitimize_pic_address (rtx orig, rtx reg)
 	    {
 	      if (!TARGET_64BIT)
 		{
-		  if (reload_in_progress)
-		    df_set_regs_ever_live (PIC_OFFSET_TABLE_REGNUM, true);
 		  new_rtx = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, op0),
 					    UNSPEC_GOTOFF);
 		  new_rtx = gen_rtx_PLUS (Pmode, new_rtx, op1);
@@ -13453,8 +13437,6 @@ legitimize_tls_address (rtx x, enum tls_model mode
 	}
       else if (flag_pic)
 	{
-	  if (reload_in_progress)
-	    df_set_regs_ever_live (PIC_OFFSET_TABLE_REGNUM, true);
 	  pic = pic_offset_table_rtx;
 	  type = TARGET_ANY_GNU_TLS ? UNSPEC_GOTNTPOFF : UNSPEC_GOTTPOFF;
 	}
@@ -16644,10 +16626,8 @@ ix86_expand_move (enum machine_mode mode, rtx oper
 	  /* dynamic-no-pic */
 	  if (MACHOPIC_INDIRECT)
 	    {
-	      rtx temp = ((reload_in_progress
-			   || ((op0 && REG_P (op0))
-			       && mode == Pmode))
-			  ? op0 : gen_reg_rtx (Pmode));
+	      rtx temp = (op0 && REG_P (op0) && mode == Pmode)
+			  ? op0 : gen_reg_rtx (Pmode);
 	      op1 = machopic_indirect_data_reference (op1, temp);
 	      if (MACHOPIC_PURE)
 		op1 = machopic_legitimize_pic_address (op1, mode,
@@ -17318,16 +17298,9 @@ ix86_expand_binary_operator (enum rtx_code code, e
  /* Emit the instruction.  */
 
   op = gen_rtx_SET (VOIDmode, dst, gen_rtx_fmt_ee (code, mode, src1, src2));
-  if (reload_in_progress)
-    {
-      /* Reload doesn't know about the flags register, and doesn't know that
-         it doesn't want to clobber it.  We can only do this with PLUS.  */
-      gcc_assert (code == PLUS);
-      emit_insn (op);
-    }
-  else if (reload_completed
-	   && code == PLUS
-	   && !rtx_equal_p (dst, src1))
+  if (reload_completed
+      && code == PLUS
+      && !rtx_equal_p (dst, src1))
     {
       /* This is going to be an LEA; avoid splitting it later.  */
       emit_insn (op);
@@ -17494,13 +17467,8 @@ ix86_expand_unary_operator (enum rtx_code code, en
   /* Emit the instruction.  */
 
   op = gen_rtx_SET (VOIDmode, dst, gen_rtx_fmt_e (code, mode, src));
-  if (reload_in_progress || code == NOT)
-    {
-      /* Reload doesn't know about the flags register, and doesn't know that
-         it doesn't want to clobber it.  */
-      gcc_assert (code == NOT);
-      emit_insn (op);
-    }
+  if (code == NOT)
+    emit_insn (op);
   else
     {
       clob = gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (CCmode, FLAGS_REG));
Index: config/i386/predicates.md
===================================================================
--- config/i386/predicates.md	(revision 206444)
+++ config/i386/predicates.md	(working copy)
@@ -549,7 +549,7 @@
 {
   if (GET_CODE (op) == SUBREG)
     op = SUBREG_REG (op);
-  if (reload_in_progress || reload_completed)
+  if (reload_completed)
     return REG_OK_FOR_INDEX_STRICT_P (op);
   else
     return REG_OK_FOR_INDEX_NONSTRICT_P (op);


More information about the Gcc-patches mailing list