Commit 5031afa7 by Jim Wilson

(record_giv): When computing replaceable, use

back_branch_in_range_p instead of looking for branches to named
labels.

From-SVN: r9675
parent bdaae9a0
...@@ -4418,46 +4418,16 @@ record_giv (v, insn, src_reg, dest_reg, mult_val, add_val, benefit, ...@@ -4418,46 +4418,16 @@ record_giv (v, insn, src_reg, dest_reg, mult_val, add_val, benefit,
} }
} }
/* Check each insn between the first and last use of the giv, /* If there are any backwards branches that go from after the
and fail if any of them are branches that jump to a named label biv update to before it, then this giv is not replaceable. */
outside this range, but still inside the loop. This catches
cases of spaghetti code where the execution order of insns
is not linear, and hence the above test fails. For example,
in the following code, j is not replaceable:
for (i = 0; i < 100; ) {
L0: j = 4*i; goto L1;
L2: k = j; goto L3;
L1: i++; goto L2;
L3: ; }
printf ("k = %d\n", k); }
This test is conservative, but this test succeeds rarely enough
that it isn't a problem. See also check_final_value below. */
if (v->replaceable) if (v->replaceable)
for (p = insn; for (b = bl->biv; b; b = b->next_iv)
INSN_UID (p) >= max_uid_for_loop if (back_branch_in_range_p (b->insn, loop_start, loop_end))
|| INSN_LUID (p) < uid_luid[regno_last_uid[REGNO (dest_reg)]]; {
p = NEXT_INSN (p)) v->replaceable = 0;
{ v->not_replaceable = 1;
if (GET_CODE (p) == JUMP_INSN && JUMP_LABEL (p) break;
&& LABEL_NAME (JUMP_LABEL (p)) }
&& ((INSN_LUID (JUMP_LABEL (p)) > INSN_LUID (loop_start)
&& (INSN_LUID (JUMP_LABEL (p))
< uid_luid[regno_first_uid[REGNO (dest_reg)]]))
|| (INSN_LUID (JUMP_LABEL (p)) < INSN_LUID (loop_end)
&& (INSN_LUID (JUMP_LABEL (p))
> uid_luid[regno_last_uid[REGNO (dest_reg)]]))))
{
v->replaceable = 0;
v->not_replaceable = 1;
if (loop_dump_stream)
fprintf (loop_dump_stream,
"Found branch outside giv lifetime.\n");
break;
}
}
} }
else else
{ {
......
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