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]

[basic-improvements] Remove unused functions in rtlanal.c.


Hi,

Attached is a patch to remove unused functions in rtlanal.c.  I
confirmed that none of cfg, 3.4, and head uses the functions being
removed.

Bootstrapped on i386-redhat-linux.  OK to apply?

Kazu Hirata

2002-09-27  Kazu Hirata  <kazu@cs.umass.edu>

	* rtlanal.c (get_jump_table_offset): Remove.
	(no_jumps_between_p): Likewise.
	(reg_referenced_between_p): Likewise.
	(insn_dependent_p): Likewise.
	(insn_dependent_p_1): Likewise.
	(reg_set_last): Likewise.
	* rtl.h: Remove corresponding prototypes.

Index: rtlanal.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/rtlanal.c,v
retrieving revision 1.138.4.2
diff -u -r1.138.4.2 rtlanal.c
--- rtlanal.c	17 Sep 2002 22:58:47 -0000	1.138.4.2
+++ rtlanal.c	27 Sep 2002 04:20:15 -0000
@@ -35,7 +35,6 @@
 /* Forward declarations */
 static int global_reg_mentioned_p_1 PARAMS ((rtx *, void *));
 static void set_of_1		PARAMS ((rtx, rtx, void *));
-static void insn_dependent_p_1	PARAMS ((rtx, rtx, void *));
 static int computed_jump_p_1	PARAMS ((rtx));
 static void parms_set 		PARAMS ((rtx, rtx, void *));
 static bool hoist_test_store		PARAMS ((rtx, rtx, regset));
@@ -349,146 +348,6 @@
   return 0;
 }
 
-/* Given a tablejump insn INSN, return the RTL expression for the offset
-   into the jump table.  If the offset cannot be determined, then return
-   NULL_RTX.
-
-   If EARLIEST is non-zero, it is a pointer to a place where the earliest
-   insn used in locating the offset was found.  */
-
-rtx
-get_jump_table_offset (insn, earliest)
-     rtx insn;
-     rtx *earliest;
-{
-  rtx label;
-  rtx table;
-  rtx set;
-  rtx old_insn;
-  rtx x;
-  rtx old_x;
-  rtx y;
-  rtx old_y;
-  int i;
-
-  if (GET_CODE (insn) != JUMP_INSN
-      || ! (label = JUMP_LABEL (insn))
-      || ! (table = NEXT_INSN (label))
-      || GET_CODE (table) != JUMP_INSN
-      || (GET_CODE (PATTERN (table)) != ADDR_VEC
-	  && GET_CODE (PATTERN (table)) != ADDR_DIFF_VEC)
-      || ! (set = single_set (insn)))
-    return NULL_RTX;
-
-  x = SET_SRC (set);
-
-  /* Some targets (eg, ARM) emit a tablejump that also
-     contains the out-of-range target.  */
-  if (GET_CODE (x) == IF_THEN_ELSE
-      && GET_CODE (XEXP (x, 2)) == LABEL_REF)
-    x = XEXP (x, 1);
-
-  /* Search backwards and locate the expression stored in X.  */
-  for (old_x = NULL_RTX; GET_CODE (x) == REG && x != old_x;
-       old_x = x, x = find_last_value (x, &insn, NULL_RTX, 0))
-    ;
-
-  /* If X is an expression using a relative address then strip
-     off the addition / subtraction of PC, PIC_OFFSET_TABLE_REGNUM,
-     or the jump table label.  */
-  if (GET_CODE (PATTERN (table)) == ADDR_DIFF_VEC
-      && (GET_CODE (x) == PLUS || GET_CODE (x) == MINUS))
-    {
-      for (i = 0; i < 2; i++)
-	{
-	  old_insn = insn;
-	  y = XEXP (x, i);
-
-	  if (y == pc_rtx || y == pic_offset_table_rtx)
-	    break;
-
-	  for (old_y = NULL_RTX; GET_CODE (y) == REG && y != old_y;
-	       old_y = y, y = find_last_value (y, &old_insn, NULL_RTX, 0))
-	    ;
-
-	  if ((GET_CODE (y) == LABEL_REF && XEXP (y, 0) == label))
-	    break;
-	}
-
-      if (i >= 2)
-	return NULL_RTX;
-
-      x = XEXP (x, 1 - i);
-
-      for (old_x = NULL_RTX; GET_CODE (x) == REG && x != old_x;
-	   old_x = x, x = find_last_value (x, &insn, NULL_RTX, 0))
-	;
-    }
-
-  /* Strip off any sign or zero extension.  */
-  if (GET_CODE (x) == SIGN_EXTEND || GET_CODE (x) == ZERO_EXTEND)
-    {
-      x = XEXP (x, 0);
-
-      for (old_x = NULL_RTX; GET_CODE (x) == REG && x != old_x;
-	   old_x = x, x = find_last_value (x, &insn, NULL_RTX, 0))
-	;
-    }
-
-  /* If X isn't a MEM then this isn't a tablejump we understand.  */
-  if (GET_CODE (x) != MEM)
-    return NULL_RTX;
-
-  /* Strip off the MEM.  */
-  x = XEXP (x, 0);
-
-  for (old_x = NULL_RTX; GET_CODE (x) == REG && x != old_x;
-       old_x = x, x = find_last_value (x, &insn, NULL_RTX, 0))
-    ;
-
-  /* If X isn't a PLUS than this isn't a tablejump we understand.  */
-  if (GET_CODE (x) != PLUS)
-    return NULL_RTX;
-
-  /* At this point we should have an expression representing the jump table
-     plus an offset.  Examine each operand in order to determine which one
-     represents the jump table.  Knowing that tells us that the other operand
-     must represent the offset.  */
-  for (i = 0; i < 2; i++)
-    {
-      old_insn = insn;
-      y = XEXP (x, i);
-
-      for (old_y = NULL_RTX; GET_CODE (y) == REG && y != old_y;
-	   old_y = y, y = find_last_value (y, &old_insn, NULL_RTX, 0))
-	;
-
-      if ((GET_CODE (y) == CONST || GET_CODE (y) == LABEL_REF)
-	  && reg_mentioned_p (label, y))
-	break;
-    }
-
-  if (i >= 2)
-    return NULL_RTX;
-
-  x = XEXP (x, 1 - i);
-
-  /* Strip off the addition / subtraction of PIC_OFFSET_TABLE_REGNUM.  */
-  if (GET_CODE (x) == PLUS || GET_CODE (x) == MINUS)
-    for (i = 0; i < 2; i++)
-      if (XEXP (x, i) == pic_offset_table_rtx)
-	{
-	  x = XEXP (x, 1 - i);
-	  break;
-	}
-
-  if (earliest)
-    *earliest = insn;
-
-  /* Return the RTL expression representing the offset.  */
-  return x;
-}
-
 /* A subroutine of global_reg_mentioned_p, returns 1 if *LOC mentions
    a global register.  */
 
@@ -714,20 +573,6 @@
   return 1;
 }
 
-/* Return 1 if in between BEG and END, exclusive of BEG and END, there is
-   no JUMP_INSN insn.  */
-
-int
-no_jumps_between_p (beg, end)
-     rtx beg, end;
-{
-  rtx p;
-  for (p = NEXT_INSN (beg); p != end; p = NEXT_INSN (p))
-    if (GET_CODE (p) == JUMP_INSN)
-      return 0;
-  return 1;
-}
-
 /* Nonzero if register REG is used in an insn between
    FROM_INSN and TO_INSN (exclusive of those two).  */
 
@@ -828,28 +673,6 @@
       return 0;
     }
 }
-
-/* Nonzero if register REG is referenced in an insn between
-   FROM_INSN and TO_INSN (exclusive of those two).  Sets of REG do
-   not count.  */
-
-int
-reg_referenced_between_p (reg, from_insn, to_insn)
-     rtx reg, from_insn, to_insn;
-{
-  rtx insn;
-
-  if (from_insn == to_insn)
-    return 0;
-
-  for (insn = NEXT_INSN (from_insn); insn != to_insn; insn = NEXT_INSN (insn))
-    if (INSN_P (insn)
-	&& (reg_referenced_p (reg, PATTERN (insn))
-	   || (GET_CODE (insn) == CALL_INSN
-	      && find_reg_fusage (insn, USE, reg))))
-      return 1;
-  return 0;
-}
 
 /* Nonzero if register REG is set or clobbered in an insn between
    FROM_INSN and TO_INSN (exclusive of those two).  */
@@ -1052,45 +875,6 @@
 
   return 0;
 }
-
-/* Return true if anything in insn X is (anti,output,true) dependent on
-   anything in insn Y.  */
-
-int
-insn_dependent_p (x, y)
-     rtx x, y;
-{
-  rtx tmp;
-
-  if (! INSN_P (x) || ! INSN_P (y))
-    abort ();
-
-  tmp = PATTERN (y);
-  note_stores (PATTERN (x), insn_dependent_p_1, &tmp);
-  if (tmp == NULL_RTX)
-    return 1;
-
-  tmp = PATTERN (x);
-  note_stores (PATTERN (y), insn_dependent_p_1, &tmp);
-  if (tmp == NULL_RTX)
-    return 1;
-
-  return 0;
-}
-
-/* A helper routine for insn_dependent_p called through note_stores.  */
-
-static void
-insn_dependent_p_1 (x, pat, data)
-     rtx x;
-     rtx pat ATTRIBUTE_UNUSED;
-     void *data;
-{
-  rtx * pinsn = (rtx *) data;
-
-  if (*pinsn && reg_mentioned_p (x, *pinsn))
-    *pinsn = NULL_RTX;
-}
 
 /* Helper function for set_of.  */
 struct set_of_data
@@ -1535,56 +1319,6 @@
     }
 
   abort ();
-}
-
-/* Return the last value to which REG was set prior to INSN.  If we can't
-   find it easily, return 0.
-
-   We only return a REG, SUBREG, or constant because it is too hard to
-   check if a MEM remains unchanged.  */
-
-rtx
-reg_set_last (x, insn)
-     rtx x;
-     rtx insn;
-{
-  rtx orig_insn = insn;
-
-  /* Scan backwards until reg_set_last_1 changed one of the above flags.
-     Stop when we reach a label or X is a hard reg and we reach a
-     CALL_INSN (if reg_set_last_last_regno is a hard reg).
-
-     If we find a set of X, ensure that its SET_SRC remains unchanged.  */
-
-  /* We compare with <= here, because reg_set_last_last_regno
-     is actually the number of the first reg *not* in X.  */
-  for (;
-       insn && GET_CODE (insn) != CODE_LABEL
-       && ! (GET_CODE (insn) == CALL_INSN
-	     && REGNO (x) <= FIRST_PSEUDO_REGISTER);
-       insn = PREV_INSN (insn))
-    if (INSN_P (insn))
-      {
-	rtx set = set_of (x, insn);
-	/* OK, this function modify our register.  See if we understand it.  */
-	if (set)
-	  {
-	    rtx last_value;
-	    if (GET_CODE (set) != SET || SET_DEST (set) != x)
-	      return 0;
-	    last_value = SET_SRC (x);
-	    if (CONSTANT_P (last_value)
-		|| ((GET_CODE (last_value) == REG
-		     || GET_CODE (last_value) == SUBREG)
-		    && ! reg_set_between_p (last_value,
-					    insn, orig_insn)))
-	      return last_value;
-	    else
-	      return 0;
-	  }
-      }
-
-  return 0;
 }
 
 /* Call FUN on each register or MEM that is stored into or clobbered by X.
Index: rtl.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/rtl.h,v
retrieving revision 1.367.4.2
diff -u -r1.367.4.2 rtl.h
--- rtl.h	17 Sep 2002 22:58:46 -0000	1.367.4.2
+++ rtl.h	27 Sep 2002 04:20:18 -0000
@@ -1582,22 +1582,18 @@
 extern int rtx_addr_varies_p		PARAMS ((rtx, int));
 extern HOST_WIDE_INT get_integer_term	PARAMS ((rtx));
 extern rtx get_related_value		PARAMS ((rtx));
-extern rtx get_jump_table_offset	PARAMS ((rtx, rtx *));
 extern int global_reg_mentioned_p	PARAMS ((rtx));
 extern int reg_mentioned_p		PARAMS ((rtx, rtx));
 extern int count_occurrences		PARAMS ((rtx, rtx, int));
 extern int reg_referenced_p		PARAMS ((rtx, rtx));
 extern int reg_used_between_p		PARAMS ((rtx, rtx, rtx));
-extern int reg_referenced_between_p	PARAMS ((rtx, rtx, rtx));
 extern int reg_set_between_p		PARAMS ((rtx, rtx, rtx));
 extern int regs_set_between_p		PARAMS ((rtx, rtx, rtx));
 extern int commutative_operand_precedence PARAMS ((rtx));
 extern int swap_commutative_operands_p	PARAMS ((rtx, rtx));
 extern int modified_between_p		PARAMS ((rtx, rtx, rtx));
 extern int no_labels_between_p		PARAMS ((rtx, rtx));
-extern int no_jumps_between_p		PARAMS ((rtx, rtx));
 extern int modified_in_p		PARAMS ((rtx, rtx));
-extern int insn_dependent_p		PARAMS ((rtx, rtx));
 extern int reg_set_p			PARAMS ((rtx, rtx));
 extern rtx single_set_2			PARAMS ((rtx, rtx));
 extern int multiple_sets		PARAMS ((rtx));
@@ -1614,7 +1610,6 @@
 extern void note_uses			PARAMS ((rtx *,
 						 void (*) (rtx *, void *),
 						 void *));
-extern rtx reg_set_last			PARAMS ((rtx, rtx));
 extern int dead_or_set_p		PARAMS ((rtx, rtx));
 extern int dead_or_set_regno_p		PARAMS ((rtx, unsigned int));
 extern rtx find_reg_note		PARAMS ((rtx, enum reg_note, rtx));


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