This is a complementary fix for the leslie3d problem.  For functions
without a regular exit (for example one that exits with exit (0))
we do not apply noreturn predictors.   The following patch notices
that edges to noreturn calls are still unlikely if they have
exactly one predecessor and is not fallthru.  In the leslie3d
case this avoids predicting the edges to STOP but still correctly
predicts the edges to the exceptional noreturn functions.

Bootstrap and regtest running on x86_64-unknown-linux-gnu, ok for trunk?

Thanks,
Richard.

2011-06-09  Richard Guenther  <rguent...@suse.de>

        * predict.c (tree_bb_level_predictions): For functions with
        no regular exit still predict the edge to a block with a noreturn
        function as not taken if it is not a fallthru edge.

Index: gcc/predict.c
===================================================================
--- gcc/predict.c       (revision 174746)
+++ gcc/predict.c       (working copy)
@@ -1613,10 +1613,18 @@ tree_bb_level_predictions (void)
 
          if (is_gimple_call (stmt))
            {
-             if ((gimple_call_flags (stmt) & ECF_NORETURN)
-                 && has_return_edges)
-               predict_paths_leading_to (bb, PRED_NORETURN,
-                                         NOT_TAKEN);
+             if ((gimple_call_flags (stmt) & ECF_NORETURN))
+               {
+                 if (has_return_edges)
+                   predict_paths_leading_to (bb, PRED_NORETURN,
+                                             NOT_TAKEN);
+                 else if (single_pred_p (bb))
+                   {
+                     edge e = single_pred_edge (bb);
+                     if (!(e->flags & EDGE_FALLTHRU))
+                       predict_edge_def (e, PRED_NORETURN, NOT_TAKEN);
+                   }
+               }
              decl = gimple_call_fndecl (stmt);
              if (decl
                  && lookup_attribute ("cold",

Reply via email to