Comments
Patch
===================================================================
@@ -24314,6 +24314,49 @@ ix86_sched_reorder(FILE *dump, int sched_verbose,
return issue_rate;
}
+/* Before reload, adjust priority of moves to/from likely spilled
+ hard registers. This reduces hard register life times and consequently
+ the chance of spill failures for enclosed instructions. */
+static int
+ix86_adjust_priority (rtx insn, int priority)
+{
+ rtx set;
+
+ if (reload_completed)
+ return priority;
+
+ if (!NONJUMP_INSN_P (insn))
+ return priority;
+
+ set = single_set (insn);
+
+ if (set)
+ {
+ rtx tmp;
+
+ /* Set priority of moves from likely spilled hard registers to maximum,
+ to schedule them as soon as possible. These are moves from
+ function argument registers at the top of the function entry. */
+ tmp = SET_SRC (set);
+ if (REG_P (tmp)
+ && HARD_REGISTER_P (tmp)
+ && ! TEST_HARD_REG_BIT (fixed_reg_set, REGNO (tmp))
+ && targetm.class_likely_spilled_p (REGNO_REG_CLASS (REGNO (tmp))))
+ return current_sched_info->sched_max_insns_priority;
+
+ /* Set priority of moves to likely spilled hard registers to minimum,
+ to schedule them as late as possible. These are moves to
+ function argument registers before function call. */
+ tmp = SET_DEST (set);
+ if (REG_P (tmp)
+ && HARD_REGISTER_P (tmp)
+ && ! TEST_HARD_REG_BIT (fixed_reg_set, REGNO (tmp))
+ && targetm.class_likely_spilled_p (REGNO_REG_CLASS (REGNO (tmp))))
+ return 0;
+ }
+
+ return priority;
+}
/* Model decoder of Core 2/i7.
@@ -39608,6 +39651,8 @@ ix86_enum_va_list (int idx, const char **pname, tr
#define TARGET_SCHED_REASSOCIATION_WIDTH ix86_reassociation_width
#undef TARGET_SCHED_REORDER
#define TARGET_SCHED_REORDER ix86_sched_reorder
+#undef TARGET_SCHED_ADJUST_PRIORITY
+#define TARGET_SCHED_ADJUST_PRIORITY ix86_adjust_priority
/* The size of the dispatch window is the total number of bytes of
object code allowed in a window. */