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]

PATCH: Remove redundant instructions after regcprop


Extended regcprop to check and remove for redundant move instructions resulting from the pass.

Paulo.

2012-08-02 Paulo Matos <Paulo.Matos@csr.com>

	* regcprop.c (copy_value): remove check for redundant moves.
	* regcprop.c (copy_value): add check for redundant moves,
	remove instructions if redundant.

--- //depot/bc/main/devHost/gcc46/gcc/gcc/regcprop.c	2011-09-06 14:29:15.000000000 0100
+++ /home/pm18/p4ws/pm18_binutils/bc/main/devHost/gcc46/gcc/gcc/regcprop.c	2011-09-06 14:29:15.000000000 0100
@@ -301,11 +301,8 @@
   unsigned int dn, sn;
   unsigned int i;
 
-  /* ??? At present, it's possible to see noop sets.  It'd be nice if
-     this were cleaned up beforehand...  */
-  if (sr == dr)
-    return;
-
+  gcc_assert(dr != sr);
+  
   /* Do not propagate copies to the stack pointer, as that can leave
      memory accesses with no scheduling dependency on the stack update.  */
   if (dr == STACK_POINTER_REGNUM)
@@ -734,9 +731,9 @@
 copyprop_hardreg_forward_1 (basic_block bb, struct value_data *vd)
 {
   bool anything_changed = false;
-  rtx insn;
+  rtx insn, next;
 
-  for (insn = BB_HEAD (bb); ; insn = NEXT_INSN (insn))
+  FOR_BB_INSNS_SAFE(bb, insn, next)
     {
       int n_ops, i, alt, predicated;
       bool is_asm, any_replacements;
@@ -755,10 +752,7 @@
 					   insn, vd);
 	    }
 
-	  if (insn == BB_END (bb))
-	    break;
-	  else
-	    continue;
+	  continue;
 	}
 
       set = single_set (insn);
@@ -966,10 +960,19 @@
 
       /* Notice copies.  */
       if (set && REG_P (SET_DEST (set)) && REG_P (SET_SRC (set)))
-	copy_value (SET_DEST (set), SET_SRC (set), vd);
-
-      if (insn == BB_END (bb))
-	break;
+      {
+        unsigned int dr = REGNO(SET_DEST(set));
+        unsigned int sr = REGNO(SET_SRC(set));
+        
+        if(dr == sr)
+        {
+          /* noop set */
+          delete_insn_and_edges(insn);
+        } 
+        else
+          copy_value (SET_DEST (set), SET_SRC (set), vd);
+      }
+      
     }
 
   return anything_changed;

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