]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
predict.c (last_basic_block_p): Remove.
authorJan Hubicka <jh@suse.cz>
Tue, 27 Feb 2007 10:21:55 +0000 (11:21 +0100)
committerJan Hubicka <hubicka@gcc.gnu.org>
Tue, 27 Feb 2007 10:21:55 +0000 (10:21 +0000)
* predict.c (last_basic_block_p): Remove.
(tree_estimate_probability): Update return heuristic for commonized
return blocks.

From-SVN: r122367

gcc/ChangeLog
gcc/predict.c

index b77c813803c5753fcf57c0f11fc1632e723d6258..dba2931e81cf63e8b4c0e8fd2ecb8f3957fbdd86 100644 (file)
@@ -1,3 +1,9 @@
+2007-02-27  Jan Hubicka  <jh@suse.cz>
+
+       * predict.c (last_basic_block_p): Remove.
+       (tree_estimate_probability): Update return heuristic for commonized
+       return blocks.
+
 2007-02-26  Brooks Moses  <brooks.moses@codesourcery.com>
 
        * Makefile.in (TEXI_GCCINSTALL_FILES): Add gcc-vers.texi dependency.
index f390ebedb4d7bcf16a9e283535fb7b0da9635f49..349ab739140a5eca6de4eea53611a1babd54c774 100644 (file)
@@ -75,7 +75,6 @@ static sreal real_zero, real_one, real_almost_one, real_br_prob_base,
 static void combine_predictions_for_insn (rtx, basic_block);
 static void dump_prediction (FILE *, enum br_predictor, int, basic_block, int);
 static void predict_paths_leading_to (basic_block, int *, enum br_predictor, enum prediction);
-static bool last_basic_block_p (basic_block);
 static void compute_function_frequency (void);
 static void choose_function_section (void);
 static bool can_predict_insn_p (rtx);
@@ -1290,20 +1289,41 @@ tree_estimate_probability (void)
        {
          /* Predict early returns to be probable, as we've already taken
             care for error returns and other cases are often used for
-            fast paths through function.  */
-         if (e->dest == EXIT_BLOCK_PTR
-             && TREE_CODE (last_stmt (bb)) == RETURN_EXPR
-             && !single_pred_p (bb))
+            fast paths through function. 
+
+            Since we've already removed the return statments, we are
+            looking for CFG like:
+
+              if (conditoinal)
+                {
+                  ..
+                  goto return_block
+                }
+              some other blocks
+            return_block:
+              return_stmt.  */
+         if (e->dest != bb->next_bb
+             && e->dest != EXIT_BLOCK_PTR
+             && single_succ_p (e->dest)
+             && single_succ_edge (e->dest)->dest == EXIT_BLOCK_PTR
+             && TREE_CODE (last_stmt (e->dest)) == RETURN_EXPR)
            {
              edge e1;
              edge_iterator ei1;
 
-             FOR_EACH_EDGE (e1, ei1, bb->preds)
-               if (!predicted_by_p (e1->src, PRED_NULL_RETURN)
-                   && !predicted_by_p (e1->src, PRED_CONST_RETURN)
-                   && !predicted_by_p (e1->src, PRED_NEGATIVE_RETURN)
-                   && !last_basic_block_p (e1->src))
-                 predict_edge_def (e1, PRED_TREE_EARLY_RETURN, NOT_TAKEN);
+             if (single_succ_p (bb))
+               {
+                 FOR_EACH_EDGE (e1, ei1, bb->preds)
+                   if (!predicted_by_p (e1->src, PRED_NULL_RETURN)
+                       && !predicted_by_p (e1->src, PRED_CONST_RETURN)
+                       && !predicted_by_p (e1->src, PRED_NEGATIVE_RETURN))
+                     predict_edge_def (e1, PRED_TREE_EARLY_RETURN, NOT_TAKEN);
+               }
+              else
+               if (!predicted_by_p (e->src, PRED_NULL_RETURN)
+                   && !predicted_by_p (e->src, PRED_CONST_RETURN)
+                   && !predicted_by_p (e->src, PRED_NEGATIVE_RETURN))
+                 predict_edge_def (e, PRED_TREE_EARLY_RETURN, NOT_TAKEN);
            }
 
          /* Look for block we are guarding (ie we dominate it,
@@ -1353,20 +1373,6 @@ tree_estimate_probability (void)
   return 0;
 }
 \f
-/* Check whether this is the last basic block of function.  Commonly
-   there is one extra common cleanup block.  */
-static bool
-last_basic_block_p (basic_block bb)
-{
-  if (bb == EXIT_BLOCK_PTR)
-    return false;
-
-  return (bb->next_bb == EXIT_BLOCK_PTR
-         || (bb->next_bb->next_bb == EXIT_BLOCK_PTR
-             && single_succ_p (bb)
-             && single_succ (bb)->next_bb == EXIT_BLOCK_PTR));
-}
-
 /* Sets branch probabilities according to PREDiction and
    FLAGS. HEADS[bb->index] should be index of basic block in that we
    need to alter branch predictions (i.e. the first of our dominators