static int one_cprop_pass PARAMS ((int, int, int));
static bool constprop_register PARAMS ((rtx, rtx, rtx, int));
static struct expr *find_bypass_set PARAMS ((int, int));
+static bool reg_killed_on_edge PARAMS ((rtx, edge));
static int bypass_block PARAMS ((basic_block, rtx, rtx));
static int bypass_conditional_jumps PARAMS ((void));
static void alloc_pre_mem PARAMS ((int, int));
}
+/* Subroutine of bypass_block that checks whether a pseudo is killed by
+ any of the instructions inserted on an edge. Jump bypassing places
+ condition code setters on CFG edges using insert_insn_on_edge. This
+ function is required to check that our data flow analysis is still
+ valid prior to commit_edge_insertions. */
+
+static bool
+reg_killed_on_edge (reg, e)
+ rtx reg;
+ edge e;
+{
+ rtx insn;
+
+ for (insn = e->insns; insn; insn = NEXT_INSN (insn))
+ if (INSN_P (insn) && reg_set_p (reg, insn))
+ return true;
+
+ return false;
+}
+
/* Subroutine of bypass_conditional_jumps that attempts to bypass the given
basic block BB which has more than one predecessor. If not NULL, SETCC
is the first instruction of BB, which is immediately followed by JUMP_INSN
JUMP. Otherwise, SETCC is NULL, and JUMP is the first insn of BB.
- Returns nonzero if a change was made. */
+ Returns nonzero if a change was made.
+
+ During the jump bypassing pass, we may place copies of SETCC instuctions
+ on CFG edges. The following routine must be careful to pay attention to
+ these inserted insns when performing its transformations. */
static int
bypass_block (bb, setcc, jump)
rtx setcc, jump;
{
rtx insn, note;
- edge e, enext;
+ edge e, enext, edest;
int i, change;
int may_be_loop_header;
if (! set)
continue;
+ /* Check the data flow is valid after edge insertions. */
+ if (e->insns && reg_killed_on_edge (reg_used->reg_rtx, e))
+ continue;
+
src = SET_SRC (pc_set (jump));
if (setcc != NULL)
new = simplify_replace_rtx (src, reg_used->reg_rtx,
SET_SRC (set->expr));
+ /* Jump bypassing may have already placed instructions on
+ edges of the CFG. We can't bypass an outgoing edge that
+ has instructions associated with it, as these insns won't
+ get executed if the incoming edge is redirected. */
+
if (new == pc_rtx)
- dest = FALLTHRU_EDGE (bb)->dest;
+ {
+ edest = FALLTHRU_EDGE (bb);
+ dest = edest->insns ? NULL : edest->dest;
+ }
else if (GET_CODE (new) == LABEL_REF)
- dest = BLOCK_FOR_INSN (XEXP (new, 0));
+ {
+ dest = BLOCK_FOR_INSN (XEXP (new, 0));
+ /* Don't bypass edges containing instructions. */
+ for (edest = bb->succ; edest; edest = edest->succ_next)
+ if (edest->dest == dest && edest->insns)
+ {
+ dest = NULL;
+ break;
+ }
+ }
else
dest = NULL;