Patchwork haifa-sched: Fix problems with cc0 in prune_ready_list

login
register
mail settings
Submitter Bernd Schmidt
Date Feb. 8, 2012, 3:01 p.m.
Message ID <4F328E64.3060601@codesourcery.com>
Download mbox | patch
Permalink /patch/140150/
State New
Headers show

Comments

Bernd Schmidt - Feb. 8, 2012, 3:01 p.m.
We found a scheduler problem while testing Coldfire targets. The
prune_ready_list function I introduced doesn't take SCHED_GROUPs into
account, which can lead to a random insn being scheduled between a cc0
setter and user. The patch below fixes it, OK? (Bootstrapped & tested
i686-linux).


Bernd
* haifa-sched.c (prune_ready_list): Ensure that if there is a
	sched-group insn, it either remains alone or the entire list is
	pruned.
Vladimir Makarov - Feb. 10, 2012, 7:01 p.m.
On 02/08/2012 10:01 AM, Bernd Schmidt wrote:
> We found a scheduler problem while testing Coldfire targets. The
> prune_ready_list function I introduced doesn't take SCHED_GROUPs into
> account, which can lead to a random insn being scheduled between a cc0
> setter and user. The patch below fixes it, OK? (Bootstrapped&  tested
> i686-linux).
>
>
Ok. Thanks, Bernd.

Patch

Index: gcc/haifa-sched.c
===================================================================
--- gcc/haifa-sched.c	(revision 357962)
+++ gcc/haifa-sched.c	(working copy)
@@ -3959,6 +3959,7 @@  prune_ready_list (state_t temp_state, bo
 		  bool shadows_only_p, bool modulo_epilogue_p)
 {
   int i;
+  bool sched_group_found = false;
 
  restart:
   for (i = 0; i < ready.n_ready; i++)
@@ -3967,13 +3968,27 @@  prune_ready_list (state_t temp_state, bo
       int cost = 0;
       const char *reason = "resource conflict";
 
-      if (modulo_epilogue_p && !DEBUG_INSN_P (insn)
-	  && INSN_EXACT_TICK (insn) == INVALID_TICK)
+      if (DEBUG_INSN_P (insn))
+	continue;
+
+      if (SCHED_GROUP_P (insn) && !sched_group_found)
+	{
+	  sched_group_found = true;
+	  if (i > 0)
+	    goto restart;
+	}
+
+      if (sched_group_found && !SCHED_GROUP_P (insn))
+	{
+	  cost = 1;
+	  reason = "not in sched group";
+	}
+      else if (modulo_epilogue_p && INSN_EXACT_TICK (insn) == INVALID_TICK)
 	{
 	  cost = max_insn_queue_index;
 	  reason = "not an epilogue insn";
 	}
-      if (shadows_only_p && !DEBUG_INSN_P (insn) && !SHADOW_P (insn))
+      else if (shadows_only_p && !SHADOW_P (insn))
 	{
 	  cost = 1;
 	  reason = "not a shadow";