[tree-ssa] ssa-dce.c marking non-INSN instructions

Jose Renau renau@cs.uiuc.edu
Sun Dec 22 11:28:00 GMT 2002


 The ssa-dce was marking as dead code all kind of instructions. A note in 
this error example:

internal compiler error: RTL flag check: INSN_DEAD_CODE_P used with 
unexpected rtx code `note' in mark_all_insn_unnecessary, at ssa-dce.c:452

 I changed the ssa-dce.c so that it only works with INSN_P(x) (INSN,
CALL_INSN, JUMP_INSN). To do that I added a check in some places. I also 
changed in RTL the kind of instructions that can be marked as dead code. 
In the rtl.h example it was only INSN type.

 This is my first patch in gcc, so verify that this is reasonable

Index: ssa-dce.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/ssa-dce.c,v
retrieving revision 1.23
diff -c -u -r1.23 ssa-dce.c
--- ssa-dce.c	16 Dec 2002 18:19:56 -0000	1.23
+++ ssa-dce.c	22 Dec 2002 19:27:11 -0000
@@ -135,8 +135,10 @@
   rtx INSN;							\
 								\
   for (INSN = get_insns (); INSN != NULL_RTX; INSN = NEXT_INSN (INSN))	\
-    if (INSN_DEAD_CODE_P (INSN)) {				\
-      CODE;							\
+    if ( INSN_P (insn) ) {					\
+      if (INSN_DEAD_CODE_P (INSN)) {				\
+        CODE;							\
+      }								\
     }								\
 }
 /* Find the label beginning block BB.  */
@@ -448,8 +450,11 @@
 mark_all_insn_unnecessary ()
 {
   rtx insn;
-  for (insn = get_insns (); insn != NULL_RTX; insn = NEXT_INSN (insn))
-    KILL_INSN (insn);
+  for (insn = get_insns (); insn != NULL_RTX; insn = NEXT_INSN (insn)) {
+    if ( INSN_P (insn))
+      KILL_INSN (insn);
+  }
+  
 }
 
 /* Find the label beginning block BB, adding one if necessary.  */
@@ -522,7 +527,7 @@
 
   /* Find inherently necessary instructions.  */
   for (insn = get_insns (); insn != NULL_RTX; insn = NEXT_INSN (insn))
-    if (find_inherently_necessary (insn))
+    if (find_inherently_necessary (insn) && INSN_P (insn))
       {
 	RESURRECT_INSN (insn);
 	VARRAY_PUSH_RTX (unprocessed_instructions, insn);
@@ -725,8 +730,11 @@
 	}
     }
   /* Release allocated memory.  */
-  for (insn = get_insns (); insn != NULL_RTX; insn = NEXT_INSN (insn))
-    RESURRECT_INSN (insn);
+  for (insn = get_insns (); insn != NULL_RTX; insn = NEXT_INSN (insn)) {
+    if ( INSN_P (insn))
+      RESURRECT_INSN (insn);
+  }
+  
   if (VARRAY_ACTIVE_SIZE (unprocessed_instructions) != 0)
     abort ();
   control_dependent_block_to_edge_map_free (cdbte);
Index: rtl.h
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/rtl.h,v
retrieving revision 1.376
diff -c -u -r1.376 rtl.h
--- rtl.h	16 Dec 2002 18:19:53 -0000	1.376
+++ rtl.h	22 Dec 2002 19:27:17 -0000
@@ -578,7 +578,7 @@
 /* 1 if RTX is an insn that is dead code.  Valid only for dead-code
    elimination phase.  */
 #define INSN_DEAD_CODE_P(RTX)						\
-  (RTL_FLAG_CHECK1("INSN_DEAD_CODE_P", (RTX), INSN)->in_struct)
+  (RTL_FLAG_CHECK3("INSN_DEAD_CODE_P", (RTX), INSN, CALL_INSN, JUMP_INSN)->in_struct)
 
 /* 1 if RTX is an insn in a delay slot and is from the target of the branch.
    If the branch insn has INSN_ANNULLED_BRANCH_P set, this insn should only be
-- 
-------------------------------------------------------------------
     Jose Renau     |    "Its not years that make one older, 
   renau@uiuc.edu   |    but disappointments." - David Arderiu
-------------------------------------------------------------------



More information about the Gcc-patches mailing list