------- Comment #5 from abel at gcc dot gnu dot org  2010-09-22 15:34 -------
The remaining problem is another case where we don't try to issue more insns
because we believe from issue_rate that this is impossible.  Full patch that
fixes all the tests with all the flags for me is below.  What it does is to fix
the situation when we don't try to issue an insn not because some target hook
said so, but because we believe that issue_rate is achieved already.  In this
case, we still try.  There is some related debug dump improvements in the
patch.

The patch will need a round of testing on a number of arches to check that I
didn't broke the honest targets and a big comment explaining why we do this
before I will submit to gcc-patches.  

diff --git a/gcc/sel-sched.c b/gcc/sel-sched.c
index 041c471..aee298a 100644
--- a/gcc/sel-sched.c
+++ b/gcc/sel-sched.c
@@ -4051,10 +4051,11 @@ sel_dfa_new_cycle (insn_t insn, fence_t fence)
 /* Invoke reorder* target hooks on the ready list.  Return the number of insns
    we can issue.  FENCE is the current fence.  */
 static int
-invoke_reorder_hooks (fence_t fence)
+invoke_reorder_hooks (fence_t fence, bool *pran_hook)
 {
   int issue_more;
-  bool ran_hook = false;
+
+  *pran_hook = false;

   /* Call the reorder hook at the beginning of the cycle, and call
      the reorder2 hook in the middle of the cycle.  */
@@ -4077,7 +4078,7 @@ invoke_reorder_hooks (fence_t fence)
           if (pipelining_p)
             ++ready.n_ready;

-          ran_hook = true;
+          *pran_hook = true;
         }
       else
         /* Initialize can_issue_more for variable_issue.  */
@@ -4106,14 +4107,14 @@ invoke_reorder_hooks (fence_t fence)
             ++ready.n_ready;
         }

-      ran_hook = true;
+      *pran_hook = true;
     }
   else
     issue_more = FENCE_ISSUE_MORE (fence);

   /* Ensure that ready list and vec_av_set are in line with each other,
      i.e. vec_av_set[i] == ready_element (&ready, i).  */
-  if (issue_more && ran_hook)
+  if (issue_more && *pran_hook)
     {
       int i, j, n;
       rtx *arr = ready.vec;
@@ -4313,7 +4314,7 @@ get_expr_cost (expr_t expr, fence_t fence)
 /* Find the best insn for scheduling, either via max_issue or just take
    the most prioritized available.  */
 static int
-choose_best_insn (fence_t fence, int privileged_n, int *index)
+choose_best_insn (fence_t fence, int privileged_n, bool ran_hook, int *index)
 {
   int can_issue = 0;

@@ -4338,6 +4339,8 @@ choose_best_insn (fence_t fence, int privileged_n, int
*index)
          if (get_expr_cost (expr, fence) < 1)
            {
              can_issue = can_issue_more;
+             if (!ran_hook && !can_issue)
+               can_issue = 1;
              *index = i;

              if (sched_verbose >= 2)
@@ -4366,6 +4369,7 @@ find_best_expr (av_set_t *av_vliw_ptr, blist_t bnds,
fence_t fence,
                 int *pneed_stall)
 {
   expr_t best;
+  bool ran_hook;

   /* Choose the best insn for scheduling via:
      1) sorting the ready list based on priority;
@@ -4376,8 +4380,8 @@ find_best_expr (av_set_t *av_vliw_ptr, blist_t bnds,
fence_t fence,
     {
       int privileged_n, index;

-      can_issue_more = invoke_reorder_hooks (fence);
-      if (can_issue_more > 0)
+      can_issue_more = invoke_reorder_hooks (fence, &ran_hook);
+      if (can_issue_more > 0 || !ran_hook)
         {
           /* Try choosing the best insn until we find one that is could be
              scheduled due to liveness restrictions on its destination
register.
@@ -4385,7 +4389,7 @@ find_best_expr (av_set_t *av_vliw_ptr, blist_t bnds,
fence_t fence,
              in the order of their priority.  */
           invoke_dfa_lookahead_guard ();
           privileged_n = calculate_privileged_insns ();
-          can_issue_more = choose_best_insn (fence, privileged_n, &index);
+          can_issue_more = choose_best_insn (fence, privileged_n, ran_hook,
&index);
           if (can_issue_more)
             best = find_expr_for_ready (index, true);
         }
@@ -4402,7 +4406,8 @@ find_best_expr (av_set_t *av_vliw_ptr, blist_t bnds,
fence_t fence,
     {
       can_issue_more = invoke_aftermath_hooks (fence, EXPR_INSN_RTX (best),
                                                can_issue_more);
-      if (can_issue_more == 0)
+      if (targetm.sched.variable_issue
+         && can_issue_more == 0)
         *pneed_stall = 1;
     }

@@ -7046,6 +7051,8 @@ reset_sched_cycles_in_current_ebb (void)
            }

          haifa_clock += i;
+          if (sched_verbose >= 2)
+            sel_print ("haifa clock: %d\n", haifa_clock);
        }
       else
        gcc_assert (haifa_cost == 0);
@@ -7064,6 +7071,7 @@ reset_sched_cycles_in_current_ebb (void)
               {
                 sel_print ("advance_state (dfa_new_cycle)\n");
                 debug_state (curr_state);
+               sel_print ("haifa clock: %d\n", haifa_clock + 1);
               }
           }

@@ -7072,8 +7080,11 @@ reset_sched_cycles_in_current_ebb (void)
          cost = state_transition (curr_state, insn);

           if (sched_verbose >= 2)
-            debug_state (curr_state);
-
+           {
+             sel_print ("scheduled insn %d, clock %d\n", INSN_UID (insn),
+                        haifa_clock + 1);
+              debug_state (curr_state);
+           }
          gcc_assert (cost < 0);
        }



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45352

Reply via email to