Re: [PATCH 5/6] haifa-sched.c: give up qsort checking when autoprefetch heuristic is in use

2017-07-31 Thread Jeff Law
On 07/15/2017 02:47 PM, Alexander Monakov wrote:
> The autopref_rank_for_schedule sub-comparator and its subroutine
> autopref_rank_data lack transitivity.  Skip checking if they are in use.
> 
> This heuristic is disabled by default everywhere except ARM and AArch64,
> so on other targets this does not suppress  checking all the time.
> 
>   * haifa-sched.c (ready_sort_real): Disable qsort checking if
> autoprefetch heuristic will be used.
> (autopref_rank_for_schedule): Add FIXME.
This is also OK once the final patch for consistency checking is approved.

jeff


[PATCH 5/6] haifa-sched.c: give up qsort checking when autoprefetch heuristic is in use

2017-07-15 Thread Alexander Monakov
The autopref_rank_for_schedule sub-comparator and its subroutine
autopref_rank_data lack transitivity.  Skip checking if they are in use.

This heuristic is disabled by default everywhere except ARM and AArch64,
so on other targets this does not suppress  checking all the time.

* haifa-sched.c (ready_sort_real): Disable qsort checking if
autoprefetch heuristic will be used.
(autopref_rank_for_schedule): Add FIXME.
---
 gcc/haifa-sched.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/gcc/haifa-sched.c b/gcc/haifa-sched.c
index af0ed27..71ad3c4 100644
--- a/gcc/haifa-sched.c
+++ b/gcc/haifa-sched.c
@@ -3081,11 +3081,18 @@ ready_sort_real (struct ready_list *ready)
   if (sched_verbose >= 4)
 stats1 = rank_for_schedule_stats;
 
+  /* autopref_rank_for_schedule lacks transitivity.  */
+  if (PARAM_VALUE (PARAM_SCHED_AUTOPREF_QUEUE_DEPTH) >= 0)
+qsort_disable_checking |= 1;
+
   if (n_ready_real == 2)
 swap_sort (first, n_ready_real);
   else if (n_ready_real > 2)
 qsort (first, n_ready_real, sizeof (rtx), rank_for_schedule);
 
+  if (PARAM_VALUE (PARAM_SCHED_AUTOPREF_QUEUE_DEPTH) >= 0)
+qsort_disable_checking &= ~1;
+
   if (sched_verbose >= 4)
 {
   rank_for_schedule_stats_diff (, _for_schedule_stats);
@@ -5704,6 +5711,7 @@ autopref_rank_data (autopref_multipass_data_t data1,
 }
 
 /* Helper function for rank_for_schedule sorting.  */
+/* FIXME: this comparator lacks transitivity and is thus invalid for qsort.  */
 static int
 autopref_rank_for_schedule (const rtx_insn *insn1, const rtx_insn *insn2)
 {
-- 
1.8.3.1