>From cdca9c3fb831a038db6eebef2a016f0c18efe1f6 Mon Sep 17 00:00:00 2001
From: Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org>
Date: Thu, 10 Apr 2014 10:56:48 +1200
Subject: [PATCH 8/8] Use rank_for_schedule to as tie-breaker in model_order_p

	* haifa-sched.c (model_order_p): Use rank_for_schedule to as
	tie-breaker.
---
 gcc/haifa-sched.c |   15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/gcc/haifa-sched.c b/gcc/haifa-sched.c
index 801b4a8..5dec35b 100644
--- a/gcc/haifa-sched.c
+++ b/gcc/haifa-sched.c
@@ -3253,7 +3253,6 @@ static int
 model_order_p (struct model_insn_info *insn1, struct model_insn_info *insn2)
 {
   unsigned int height1, height2;
-  unsigned int priority1, priority2;
 
   /* Prefer instructions with a higher model priority.  */
   if (insn1->model_priority != insn2->model_priority)
@@ -3281,14 +3280,12 @@ model_order_p (struct model_insn_info *insn1, struct model_insn_info *insn2)
     return insn1->depth > insn2->depth;
 
   /* We have no real preference between INSN1 an INSN2 as far as attempts
-     to reduce pressure go.  Prefer instructions with higher priorities.  */
-  priority1 = INSN_PRIORITY (insn1->insn);
-  priority2 = INSN_PRIORITY (insn2->insn);
-  if (priority1 != priority2)
-    return priority1 > priority2;
-
-  /* Use the original rtl sequence as a tie-breaker.  */
-  return insn1 < insn2;
+     to reduce pressure go.  Fallback to non-pressure sensitive heuristics.  */
+  gcc_assert (sched_pressure == SCHED_PRESSURE_MODEL);
+  sched_pressure = SCHED_PRESSURE_NONE;
+  int res = rank_for_schedule (&insn2->insn, &insn1->insn) < 0;
+  sched_pressure = SCHED_PRESSURE_MODEL;
+  return res;
 }
 
 /* Add INSN to the model worklist immediately after PREV.  Add it to the
-- 
1.7.9.5

