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: PATCH: Check all insns in fallthru to see if label is mentioned


On Wed, Oct 03, 2001 at 03:08:12PM -0400, John David Anglin wrote:
> 	* cfgcleanup.c (label_mentioned_p): New function.
> 	(try_optimize_cfg): Use it.

Rather than search, this check ought to be

              && (!(mode & CLEANUP_PRE_SIBCALL)
                  || !tail_recursion_label_p (b->head))
-             /* If previous block ends with condjump jumping to next BB,
-                we can't delete the label.  */
-             && (b->pred->src == ENTRY_BLOCK_PTR
-                 || !reg_mentioned_p (b->head, b->pred->src->end)))
+	      /* If the previous block ends with a branch to this block,
+		 we can't delete the label.  Normally this is a condjump
+		 that is yet to be simplified, but if CASE_DROPS_THRU,
+		 this can be a tablejump with some element going to the
+		 same place as the default (fallthru).  */
+	      && (b->pred->src == ENTRY_BLOCK_PTR
+		  || GET_CODE (b->pred->src->end) != JUMP_INSN
+		  || ! label_is_jump_target_p (b->head, b->pred->src->end)))


/* Return true if LABEL is a target of JUMP_INSN.  This applies only
   to non-complex jumps.  That is, direct unconditional, conditional,
   and tablejumps, but not computed jumps or returns.  It also does
   not apply to the fallthru case of a conditional jump.  */

bool
label_is_jump_target_p (label, jump_insn)
     rtx label, jump_insn;
{
  rtx tmp = JUMP_LABEL (jump_insn);

  if (label == tmp)
    return true;

  if (tmp != NULL_RTX
      && (tmp = NEXT_INSN (tmp)) != NULL_RTX
      && GET_CODE (tmp) == JUMP_INSN
      && (tmp = PATTERN (tmp),
	  GET_CODE (tmp) == ADDR_VEC
	  || GET_CODE (tmp) == ADDR_DIFF_VEC))
    {
      rtvec vec = XVEC (tmp, GET_CODE (tmp) == ADDR_DIFF_VEC);
      int i, veclen = GET_NUM_ELEM (vec);

      for (i = 0; i < veclen; ++i)
	if (XEXP (RTVEC_ELT (vec, i), 0) == label)
	  return true;
    }

  return false;
}

> 	* rtl.c (rtx_equal_p): Check for null pointers when comparing rtx
> 	strings.

The cfgcleanup thing aside, this is ok.


r~


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