sched-int.h (schedule_block): Adjust declaration.
authorBernd Schmidt <bernds@codesourcery.com>
Mon, 8 Oct 2012 11:26:16 +0000 (11:26 +0000)
committerBernd Schmidt <bernds@gcc.gnu.org>
Mon, 8 Oct 2012 11:26:16 +0000 (11:26 +0000)
* sched-int.h (schedule_block): Adjust declaration.
* sched-rgn.c (bb_state_array, bb_state): New static variables.
(sched_rgn_init): Initialize them.
(sched_rgn_free): Free them.
(schedule_region): Save scheduling state for future blocks, and
pass such state to schedule_block.
* params.def (PARAM_SCHED_STATE_EDGE_PROB_CUTOFF): New.
* doc/invoke.texi (--param): Document it.
* haifa-sched.c (schedule_block): New arg init_state.  Use it to
initialize state if nonnull.  All callers changed.
Call advance_one_cycle after scheduling.

From-SVN: r192203

gcc/ChangeLog
gcc/doc/invoke.texi
gcc/haifa-sched.c
gcc/params.def
gcc/sched-ebb.c
gcc/sched-int.h
gcc/sched-rgn.c

index 9a388260a34fc3e04a63eb98e5135da5b6d7fdc9..a9f6c47910bc35254075fa990022101c9803e000 100644 (file)
@@ -1,3 +1,17 @@
+2012-10-08  Bernd Schmidt  <bernds@codesourcery.com>
+
+       * sched-int.h (schedule_block): Adjust declaration.
+       * sched-rgn.c (bb_state_array, bb_state): New static variables.
+       (sched_rgn_init): Initialize them.
+       (sched_rgn_free): Free them.
+       (schedule_region): Save scheduling state for future blocks, and
+       pass such state to schedule_block.
+       * params.def (PARAM_SCHED_STATE_EDGE_PROB_CUTOFF): New.
+       * doc/invoke.texi (--param): Document it.
+       * haifa-sched.c (schedule_block): New arg init_state.  Use it to
+       initialize state if nonnull.  All callers changed.
+       Call advance_one_cycle after scheduling.
+
 2012-10-08  Georg-Johann Lay  <avr@gjlay.de>
 
        PR target/54854
index 9d4859797b7e95fc31e8f722798fb4ec7bf9d383..a9a79343985bdc6bcd070453446a40e996199612 100644 (file)
@@ -9242,6 +9242,11 @@ The minimal probability of speculation success (in percents), so that
 speculative insns are scheduled.
 The default value is 40.
 
+@item sched-spec-state-edge-prob-cutoff
+The minimum probability an edge must have for the scheduler to save its
+state across it.
+The default value is 10.
+
 @item sched-mem-true-dep-cost
 Minimal distance (in CPU cycles) between store and load targeting same
 memory locations.  The default value is 1.
index 8072beb85ffa2bba5349ec325b0da980089ed651..f45caf48771c514388e3c7ac340ad299de2b133c 100644 (file)
@@ -5840,7 +5840,7 @@ verify_shadows (void)
    region.  */
 
 bool
-schedule_block (basic_block *target_bb)
+schedule_block (basic_block *target_bb, state_t init_state)
 {
   int i;
   bool success = modulo_ii == 0;
@@ -5875,7 +5875,10 @@ schedule_block (basic_block *target_bb)
   if (sched_verbose)
     dump_new_block_header (0, *target_bb, head, tail);
 
-  state_reset (curr_state);
+  if (init_state == NULL)
+    state_reset (curr_state);
+  else
+    memcpy (curr_state, init_state, dfa_state_size);
 
   /* Clear the ready list.  */
   ready.first = ready.veclen - 1;
@@ -6335,6 +6338,7 @@ schedule_block (basic_block *target_bb)
   if (ls.modulo_epilogue)
     success = true;
  end_schedule:
+  advance_one_cycle ();
   perform_replacements_new_cycle ();
   if (modulo_ii > 0)
     {
index a4c930b9e3cc4abd293e76230c8e58c24088645f..8733f1ba631f899c0d0374d9d8144e40ab9be894 100644 (file)
@@ -611,6 +611,11 @@ DEFPARAM(PARAM_SCHED_SPEC_PROB_CUTOFF,
          "The minimal probability of speculation success (in percents), so that speculative insn will be scheduled.",
          40, 0, 100)
 
+DEFPARAM(PARAM_SCHED_STATE_EDGE_PROB_CUTOFF,
+         "sched-state-edge-prob-cutoff",
+         "The minimum probability an edge must have for the scheduler to save its state across it.",
+         10, 0, 100)
+
 DEFPARAM(PARAM_SELSCHED_MAX_LOOKAHEAD,
          "selsched-max-lookahead",
          "The maximum size of the lookahead window of selective scheduling",
index 372d1081b4fbd4507f1eacbc2b45bb02fd0d904d..9e524f9f13e9840f4059420b7e85c37a77363ae2 100644 (file)
@@ -544,7 +544,7 @@ schedule_ebb (rtx head, rtx tail, bool modulo_scheduling)
 
   /* Make ready list big enough to hold all the instructions from the ebb.  */
   sched_extend_ready_list (rgn_n_insns);
-  success = schedule_block (&target_bb);
+  success = schedule_block (&target_bb, NULL);
   gcc_assert (success || modulo_scheduling);
 
   /* Free ready list.  */
index 32bdeb42ab9ce70e1acb3dd59fb3f10303024676..d3a15aa90a7237cc4a58ce9b791d2aaaa70437cb 100644 (file)
@@ -1321,7 +1321,7 @@ extern int dep_cost (dep_t);
 extern int set_priorities (rtx, rtx);
 
 extern void sched_setup_bb_reg_pressure_info (basic_block, rtx);
-extern bool schedule_block (basic_block *);
+extern bool schedule_block (basic_block *, state_t);
 
 extern int cycle_issued_insns;
 extern int issue_rate;
index 5d39a36d7fac93cd150eb01963b42b1702b12f21..ba85238e6fd2a3b04e2fce9157ed3dfa62484d0b 100644 (file)
@@ -124,6 +124,9 @@ int current_blocks;
 static basic_block *bblst_table;
 static int bblst_size, bblst_last;
 
+static char *bb_state_array;
+static state_t *bb_state;
+
 /* Target info declarations.
 
    The block currently being scheduled is referred to as the "target" block,
@@ -2982,9 +2985,21 @@ schedule_region (int rgn)
       curr_bb = first_bb;
       if (dbg_cnt (sched_block))
         {
-          schedule_block (&curr_bb);
+         edge f;
+
+          schedule_block (&curr_bb, bb_state[first_bb->index]);
           gcc_assert (EBB_FIRST_BB (bb) == first_bb);
           sched_rgn_n_insns += sched_n_insns;
+         f = find_fallthru_edge (last_bb->succs);
+         if (f && f->probability * 100 / REG_BR_PROB_BASE >=
+             PARAM_VALUE (PARAM_SCHED_STATE_EDGE_PROB_CUTOFF))
+           {
+             memcpy (bb_state[f->dest->index], curr_state,
+                     dfa_state_size);
+             if (sched_verbose >= 5)
+               fprintf (sched_dump, "saving state for edge %d->%d\n",
+                        f->src->index, f->dest->index);
+           }
         }
       else
         {
@@ -3017,6 +3032,8 @@ schedule_region (int rgn)
 void
 sched_rgn_init (bool single_blocks_p)
 {
+  int i;
+
   min_spec_prob = ((PARAM_VALUE (PARAM_MIN_SPEC_PROB) * REG_BR_PROB_BASE)
                    / 100);
 
@@ -3028,6 +3045,23 @@ sched_rgn_init (bool single_blocks_p)
   CONTAINING_RGN (ENTRY_BLOCK) = -1;
   CONTAINING_RGN (EXIT_BLOCK) = -1;
 
+  if (!sel_sched_p ())
+    {
+      bb_state_array = (char *) xmalloc (last_basic_block * dfa_state_size);
+      bb_state = XNEWVEC (state_t, last_basic_block);
+      for (i = 0; i < last_basic_block; i++)
+       {
+         bb_state[i] = (state_t) (bb_state_array + i * dfa_state_size);
+      
+         state_reset (bb_state[i]);
+       }
+    }
+  else
+    {
+      bb_state_array = NULL;
+      bb_state = NULL;
+    }
+
   /* Compute regions for scheduling.  */
   if (single_blocks_p
       || n_basic_blocks == NUM_FIXED_BLOCKS + 1
@@ -3064,6 +3098,9 @@ sched_rgn_init (bool single_blocks_p)
 void
 sched_rgn_finish (void)
 {
+  free (bb_state_array);
+  free (bb_state);
+
   /* Reposition the prologue and epilogue notes in case we moved the
      prologue/epilogue insns.  */
   if (reload_completed)