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.

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";

Reply via email to