Commit 77472c5a by Tom Wood

(delete_computation): Derived from delete_jump.

(delete_jump): Use delete_computation.

From-SVN: r1944
parent cdd8c058
...@@ -108,6 +108,7 @@ void redirect_tablejump (); ...@@ -108,6 +108,7 @@ void redirect_tablejump ();
static int delete_labelref_insn (); static int delete_labelref_insn ();
static void mark_jump_label (); static void mark_jump_label ();
void delete_jump (); void delete_jump ();
void delete_computation ();
static void delete_from_jump_chain (); static void delete_from_jump_chain ();
static int tension_vector_labels (); static int tension_vector_labels ();
static void find_cross_jump (); static void find_cross_jump ();
...@@ -2820,13 +2821,12 @@ delete_jump (insn) ...@@ -2820,13 +2821,12 @@ delete_jump (insn)
rtx insn; rtx insn;
{ {
register rtx x = PATTERN (insn); register rtx x = PATTERN (insn);
register rtx prev;
if (GET_CODE (x) == SET if (GET_CODE (x) == SET
&& GET_CODE (SET_DEST (x)) == PC) && GET_CODE (SET_DEST (x)) == PC)
{ {
prev = prev_nonnote_insn (insn);
#ifdef HAVE_cc0 #ifdef HAVE_cc0
rtx prev = prev_nonnote_insn (insn);
/* We assume that at this stage /* We assume that at this stage
CC's are always set explicitly CC's are always set explicitly
and always immediately before the jump that and always immediately before the jump that
...@@ -2844,87 +2844,100 @@ delete_jump (insn) ...@@ -2844,87 +2844,100 @@ delete_jump (insn)
REG_NOTES (prev) = gen_rtx (EXPR_LIST, REG_UNUSED, REG_NOTES (prev) = gen_rtx (EXPR_LIST, REG_UNUSED,
cc0_rtx, REG_NOTES (prev)); cc0_rtx, REG_NOTES (prev));
} }
#else #endif
{ /* Now delete the jump insn itself. */
rtx note; delete_computation (insn);
}
}
/* If we are running before flow.c, we need do nothing since flow.c /* Delete INSN and recursively delete insns that compute values used only
will delete the set of the condition code if it is dead. We also by INSN. This uses the REG_DEAD notes computed during flow analysis.
can't know if the register being used as the condition code is If we are running before flow.c, we need do nothing since flow.c will
dead or not at this point. delete dead code. We also can't know if the registers being used are
dead or not at this point.
Otherwise, look at all our REG_DEAD notes. If a previous insn Otherwise, look at all our REG_DEAD notes. If a previous insn does
does nothing other than set a register that dies in this jump, nothing other than set a register that dies in this insn, we can delete
we can delete the insn. */ that insn as well. */
for (note = REG_NOTES (insn); note; note = XEXP (note, 1)) void
{ delete_computation (insn)
rtx our_prev; rtx insn;
{
#ifndef HAVE_cc0
rtx note, next;
if (REG_NOTE_KIND (note) != REG_DEAD for (note = REG_NOTES (insn); note; note = next)
/* Verify that the REG_NOTE has a legal value. */ {
|| GET_CODE (XEXP (note, 0)) != REG) rtx our_prev;
continue;
for (our_prev = prev_nonnote_insn (insn); next = XEXP (note, 1);
our_prev && GET_CODE (our_prev) == INSN;
our_prev = prev_nonnote_insn (our_prev))
{
/* If we reach a SEQUENCE, it is too complex to try to
do anything with it, so give up. */
if (GET_CODE (PATTERN (our_prev)) == SEQUENCE)
break;
if (GET_CODE (PATTERN (our_prev)) == USE if (REG_NOTE_KIND (note) != REG_DEAD
&& GET_CODE (XEXP (PATTERN (our_prev), 0)) == INSN) /* Verify that the REG_NOTE is legitimate. */
/* reorg creates USEs that look like this. We leave them || GET_CODE (XEXP (note, 0)) != REG)
alone because reorg needs them for its own purposes. */ continue;
break;
if (reg_set_p (XEXP (note, 0), PATTERN (our_prev))) for (our_prev = prev_nonnote_insn (insn);
{ our_prev && GET_CODE (our_prev) == INSN;
if (FIND_REG_INC_NOTE (our_prev, NULL_RTX)) our_prev = prev_nonnote_insn (our_prev))
break; {
/* If we reach a SEQUENCE, it is too complex to try to
do anything with it, so give up. */
if (GET_CODE (PATTERN (our_prev)) == SEQUENCE)
break;
if (GET_CODE (PATTERN (our_prev)) == PARALLEL) if (GET_CODE (PATTERN (our_prev)) == USE
{ && GET_CODE (XEXP (PATTERN (our_prev), 0)) == INSN)
/* If we find a SET of something else, we can't /* reorg creates USEs that look like this. We leave them
delete the insn. */ alone because reorg needs them for its own purposes. */
break;
int i; if (reg_set_p (XEXP (note, 0), PATTERN (our_prev)))
{
if (FIND_REG_INC_NOTE (our_prev, NULL_RTX))
break;
for (i = 0; i < XVECLEN (PATTERN (our_prev), 0); i++) if (GET_CODE (PATTERN (our_prev)) == PARALLEL)
{ {
rtx part = XVECEXP (PATTERN (our_prev), 0, i); /* If we find a SET of something else, we can't
delete the insn. */
if (GET_CODE (part) == SET int i;
&& SET_DEST (part) != XEXP (note, 0))
break;
}
if (i == XVECLEN (PATTERN (our_prev), 0)) for (i = 0; i < XVECLEN (PATTERN (our_prev), 0); i++)
delete_insn (our_prev); {
} rtx part = XVECEXP (PATTERN (our_prev), 0, i);
else if (GET_CODE (PATTERN (our_prev)) == SET
&& SET_DEST (PATTERN (our_prev)) == XEXP (note, 0))
delete_insn (our_prev);
break; if (GET_CODE (part) == SET
} && SET_DEST (part) != XEXP (note, 0))
break;
}
/* If OUR_PREV references the register that dies here, if (i == XVECLEN (PATTERN (our_prev), 0))
it is an additional use. Hence any prior SET isn't delete_computation (our_prev);
dead. */ }
if (reg_overlap_mentioned_p (XEXP (note, 0), else if (GET_CODE (PATTERN (our_prev)) == SET
PATTERN (our_prev))) && SET_DEST (PATTERN (our_prev)) == XEXP (note, 0))
break; delete_computation (our_prev);
}
} break;
} }
#endif
/* Now delete the jump insn itself. */ /* If OUR_PREV references the register that dies here, it is an
delete_insn (insn); additional use. Hence any prior SET isn't dead. However, this
insn becomes the new place for the REG_DEAD note. */
if (reg_overlap_mentioned_p (XEXP (note, 0),
PATTERN (our_prev)))
{
XEXP (note, 1) = REG_NOTES (our_prev);
REG_NOTES (our_prev) = note;
break;
}
}
} }
#endif /* Don't HAVE_cc0 */
delete_insn (insn);
} }
/* Delete insn INSN from the chain of insns and update label ref counts. /* Delete insn INSN from the chain of insns and update label ref counts.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment