From patchwork Wed Feb 8 15:01:56 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: haifa-sched: Fix problems with cc0 in prune_ready_list Date: Wed, 08 Feb 2012 05:01:56 -0000 From: Bernd Schmidt X-Patchwork-Id: 140150 Message-Id: <4F328E64.3060601@codesourcery.com> To: GCC Patches 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";