Commit 63387a85 by Maxim Kuvyrkov Committed by Maxim Kuvyrkov

Fix scheduling undeterminism from sorting with DEBUG_INSNs

	* haifa-sched.c (INSN_RFS_DEBUG_ORIG_ORDER): New access macro.
	(rank_for_schedule_debug): Split from ...
	(rank_for_schedule): ... this.
	(ready_sort): Sort DEBUG_INSNs separately from normal INSNs.
	* sched-int.h (struct _haifa_insn_data): New field rfs_debug_orig_order.

From-SVN: r220316
parent b4fbcb1b
2015-02-01 Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org>
* haifa-sched.c (INSN_RFS_DEBUG_ORIG_ORDER): New access macro.
(rank_for_schedule_debug): Split from ...
(rank_for_schedule): ... this.
(ready_sort): Sort DEBUG_INSNs separately from normal INSNs.
* sched-int.h (struct _haifa_insn_data): New field rfs_debug_orig_order.
2015-01-31 Sandra Loosemore <sandra@codesourcery.com> 2015-01-31 Sandra Loosemore <sandra@codesourcery.com>
* doc/md.texi (Machine Constraints): Alphabetize table by target. * doc/md.texi (Machine Constraints): Alphabetize table by target.
......
...@@ -250,6 +250,10 @@ struct common_sched_info_def *common_sched_info; ...@@ -250,6 +250,10 @@ struct common_sched_info_def *common_sched_info;
/* The minimal value of the INSN_TICK of an instruction. */ /* The minimal value of the INSN_TICK of an instruction. */
#define MIN_TICK (-max_insn_queue_index) #define MIN_TICK (-max_insn_queue_index)
/* Original order of insns in the ready list.
Used to keep order of normal insns while separating DEBUG_INSNs. */
#define INSN_RFS_DEBUG_ORIG_ORDER(INSN) (HID (INSN)->rfs_debug_orig_order)
/* The deciding reason for INSN's place in the ready list. */ /* The deciding reason for INSN's place in the ready list. */
#define INSN_LAST_RFS_WIN(INSN) (HID (INSN)->last_rfs_win) #define INSN_LAST_RFS_WIN(INSN) (HID (INSN)->last_rfs_win)
...@@ -2597,20 +2601,15 @@ rfs_result (enum rfs_decision decision, int result, rtx tmp, rtx tmp2) ...@@ -2597,20 +2601,15 @@ rfs_result (enum rfs_decision decision, int result, rtx tmp, rtx tmp2)
return result; return result;
} }
/* Returns a positive value if x is preferred; returns a negative value if /* Sorting predicate to move DEBUG_INSNs to the top of ready list, while
y is preferred. Should never return 0, since that will make the sort keeping normal insns in original order. */
unstable. */
static int static int
rank_for_schedule (const void *x, const void *y) rank_for_schedule_debug (const void *x, const void *y)
{ {
rtx_insn *tmp = *(rtx_insn * const *) y; rtx_insn *tmp = *(rtx_insn * const *) y;
rtx_insn *tmp2 = *(rtx_insn * const *) x; rtx_insn *tmp2 = *(rtx_insn * const *) x;
int tmp_class, tmp2_class;
int val, priority_val, info_val, diff;
if (MAY_HAVE_DEBUG_INSNS)
{
/* Schedule debug insns as early as possible. */ /* Schedule debug insns as early as possible. */
if (DEBUG_INSN_P (tmp) && !DEBUG_INSN_P (tmp2)) if (DEBUG_INSN_P (tmp) && !DEBUG_INSN_P (tmp2))
return rfs_result (RFS_DEBUG, -1, tmp, tmp2); return rfs_result (RFS_DEBUG, -1, tmp, tmp2);
...@@ -2619,7 +2618,21 @@ rank_for_schedule (const void *x, const void *y) ...@@ -2619,7 +2618,21 @@ rank_for_schedule (const void *x, const void *y)
else if (DEBUG_INSN_P (tmp) && DEBUG_INSN_P (tmp2)) else if (DEBUG_INSN_P (tmp) && DEBUG_INSN_P (tmp2))
return rfs_result (RFS_DEBUG, INSN_LUID (tmp) - INSN_LUID (tmp2), return rfs_result (RFS_DEBUG, INSN_LUID (tmp) - INSN_LUID (tmp2),
tmp, tmp2); tmp, tmp2);
} else
return INSN_RFS_DEBUG_ORIG_ORDER (tmp2) - INSN_RFS_DEBUG_ORIG_ORDER (tmp);
}
/* Returns a positive value if x is preferred; returns a negative value if
y is preferred. Should never return 0, since that will make the sort
unstable. */
static int
rank_for_schedule (const void *x, const void *y)
{
rtx_insn *tmp = *(rtx_insn * const *) y;
rtx_insn *tmp2 = *(rtx_insn * const *) x;
int tmp_class, tmp2_class;
int val, priority_val, info_val, diff;
if (live_range_shrinkage_p) if (live_range_shrinkage_p)
{ {
...@@ -3075,13 +3088,21 @@ ready_sort (struct ready_list *ready) ...@@ -3075,13 +3088,21 @@ ready_sort (struct ready_list *ready)
{ {
int i; int i;
rtx_insn **first = ready_lastpos (ready); rtx_insn **first = ready_lastpos (ready);
int n_ready_non_debug = ready->n_ready;
if (sched_pressure == SCHED_PRESSURE_WEIGHTED) for (i = 0; i < ready->n_ready; ++i)
{ {
for (i = 0; i < ready->n_ready; i++) if (DEBUG_INSN_P (first[i]))
if (!DEBUG_INSN_P (first[i])) --n_ready_non_debug;
else
{
INSN_RFS_DEBUG_ORIG_ORDER (first[i]) = i;
if (sched_pressure == SCHED_PRESSURE_WEIGHTED)
setup_insn_reg_pressure_info (first[i]); setup_insn_reg_pressure_info (first[i]);
} }
}
if (sched_pressure == SCHED_PRESSURE_MODEL if (sched_pressure == SCHED_PRESSURE_MODEL
&& model_curr_point < model_num_insns) && model_curr_point < model_num_insns)
model_set_excess_costs (first, ready->n_ready); model_set_excess_costs (first, ready->n_ready);
...@@ -3090,10 +3111,17 @@ ready_sort (struct ready_list *ready) ...@@ -3090,10 +3111,17 @@ ready_sort (struct ready_list *ready)
if (sched_verbose >= 4) if (sched_verbose >= 4)
stats1 = rank_for_schedule_stats; stats1 = rank_for_schedule_stats;
if (ready->n_ready == 2) if (n_ready_non_debug < ready->n_ready)
swap_sort (first, ready->n_ready); /* Separate DEBUG_INSNS from normal insns. DEBUG_INSNs go to the end
else if (ready->n_ready > 2) of array. */
qsort (first, ready->n_ready, sizeof (rtx), rank_for_schedule); qsort (first, ready->n_ready, sizeof (rtx), rank_for_schedule_debug);
else
{
if (n_ready_non_debug == 2)
swap_sort (first, n_ready_non_debug);
else if (n_ready_non_debug > 2)
qsort (first, n_ready_non_debug, sizeof (rtx), rank_for_schedule);
}
if (sched_verbose >= 4) if (sched_verbose >= 4)
{ {
......
...@@ -917,6 +917,9 @@ struct _haifa_insn_data ...@@ -917,6 +917,9 @@ struct _haifa_insn_data
int reg_pressure_excess_cost_change; int reg_pressure_excess_cost_change;
int model_index; int model_index;
/* Original order of insns in the ready list. */
int rfs_debug_orig_order;
/* The deciding reason for INSN's place in the ready list. */ /* The deciding reason for INSN's place in the ready list. */
int last_rfs_win; int last_rfs_win;
......
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