- prev = prev_nonnote_insn (insn);
- add_dependence (insn, prev, REG_DEP_ANTI);
+ free_INSN_LIST_list (&LOG_LINKS (insn));
+}
+
+/* All insns in a scheduling group except the first should only have
+ dependencies on the previous insn in the group. So we find the
+ first instruction in the scheduling group by walking the dependence
+ chains backwards. Then we add the dependencies for the group to
+ the previous nonnote insn. */
+
+static void
+fixup_sched_groups (rtx insn)
+{
+ rtx link;
+
+ for (link = LOG_LINKS (insn); link ; link = XEXP (link, 1))
+ {
+ rtx i = insn;
+ do
+ {
+ i = prev_nonnote_insn (i);
+
+ if (XEXP (link, 0) == i)
+ goto next_link;
+ } while (SCHED_GROUP_P (i));
+ add_dependence (i, XEXP (link, 0), REG_NOTE_KIND (link));
+ next_link:;
+ }
+
+ delete_all_dependences (insn);
+
+ if (BLOCK_FOR_INSN (insn) == BLOCK_FOR_INSN (prev_nonnote_insn (insn)))
+ add_dependence (insn, prev_nonnote_insn (insn), REG_DEP_ANTI);