+2012-11-28 Steven Bosscher <steven@gcc.gnu.org>
+
+ PR rtl-optimization/55006
+ * loop-unroll.c (struct iv_to_split): Add new 'orig_var' member.
+ (analyze_iv_to_split_insn): Record it.
+ (maybe_strip_eq_note_for_split_iv): New function to remove REG_EQUAL
+ notes that refer to IVs that are being split.
+ (apply_opt_in_copies): Use maybe_strip_eq_note_for_split_iv. Twice.
+ Use FOR_BB_INSNS_SAFE.
+
2012-11-27 Steven Bosscher <steven@gcc.gnu.org>
* rtl.h (debug_bb_n_slim, debug_bb_slim, debug_insn_slim): Remove
struct iv_to_split
{
rtx insn; /* The insn in that the induction variable occurs. */
+ rtx orig_var; /* The variable (register) for the IV before split. */
rtx base_var; /* The variable on that the values in the further
iterations are based. */
rtx step; /* Step of the induction variable. */
/* Record the insn to split. */
ivts = XNEW (struct iv_to_split);
ivts->insn = insn;
+ ivts->orig_var = dest;
ivts->base_var = NULL_RTX;
ivts->step = iv.step;
ivts->next = NULL;
emit_insn_after (seq, insn);
}
+/* Strip away REG_EQUAL notes for IVs we're splitting.
+
+ Updating REG_EQUAL notes for IVs we split is tricky: We
+ cannot tell until after unrolling, DF-rescanning, and liveness
+ updating, whether an EQ_USE is reached by the split IV while
+ the IV reg is still live. See PR55006.
+
+ ??? We cannot use remove_reg_equal_equiv_notes_for_regno,
+ because RTL loop-iv requires us to defer rescanning insns and
+ any notes attached to them. So resort to old techniques... */
+
+static void
+maybe_strip_eq_note_for_split_iv (struct opt_info *opt_info, rtx insn)
+{
+ struct iv_to_split *ivts;
+ rtx note = find_reg_equal_equiv_note (insn);
+ if (! note)
+ return;
+ for (ivts = opt_info->iv_to_split_head; ivts; ivts = ivts->next)
+ if (reg_mentioned_p (ivts->orig_var, note))
+ {
+ remove_note (insn, note);
+ return;
+ }
+}
+
/* Apply loop optimizations in loop copies using the
data which gathered during the unrolling. Structure
OPT_INFO record that data.
unrolling);
bb->aux = 0;
orig_insn = BB_HEAD (orig_bb);
- for (insn = BB_HEAD (bb); insn != NEXT_INSN (BB_END (bb)); insn = next)
+ FOR_BB_INSNS_SAFE (bb, insn, next)
{
- next = NEXT_INSN (insn);
if (!INSN_P (insn)
|| (DEBUG_INSN_P (insn)
&& TREE_CODE (INSN_VAR_LOCATION_DECL (insn)) == LABEL_DECL))
/* Apply splitting iv optimization. */
if (opt_info->insns_to_split)
{
+ maybe_strip_eq_note_for_split_iv (opt_info, insn);
+
ivts = (struct iv_to_split *)
htab_find (opt_info->insns_to_split, &ivts_templ);
ivts_templ.insn = orig_insn;
if (opt_info->insns_to_split)
{
+ maybe_strip_eq_note_for_split_iv (opt_info, orig_insn);
+
ivts = (struct iv_to_split *)
htab_find (opt_info->insns_to_split, &ivts_templ);
if (ivts)