Fix finding of a first match predictor
authorMartin Liska <mliska@suse.cz>
Thu, 16 Jun 2016 19:25:56 +0000 (21:25 +0200)
committerMartin Liska <marxin@gcc.gnu.org>
Thu, 16 Jun 2016 19:25:56 +0000 (19:25 +0000)
* predict.c (combine_predictions_for_insn): When we find a first
match predictor, we should consider just predictors with
PRED_FLAG_FIRST_MATCH.  Print either first match (if any) or
DS theory predictor.
(combine_predictions_for_bb): Likewise.

From-SVN: r237539

gcc/ChangeLog
gcc/predict.c

index 20e4ecdb4e046f352d669f3bd026d19141eabdd8..f07df860263fe291eee34da71b5252ff722b8f5c 100644 (file)
@@ -1,3 +1,11 @@
+2016-06-16  Martin Liska  <mliska@suse.cz>
+
+       * predict.c (combine_predictions_for_insn): When we find a first
+       match predictor, we should consider just predictors with
+       PRED_FLAG_FIRST_MATCH.  Print either first match (if any) or
+       DS theory predictor.
+       (combine_predictions_for_bb): Likewise.
+
 2016-06-16  Jakub Jelinek  <jakub@redhat.com>
 
        * gimplify.c (gimplify_scan_omp_clauses): Handle COMPONENT_REFs
index bafcc96fbc5c0c6b255d56fd952c7abe47fa3b80..642bd6287a0dbffa4bcd1f923ee82b97b0b02a37 100644 (file)
@@ -835,7 +835,8 @@ combine_predictions_for_insn (rtx_insn *insn, basic_block bb)
        int probability = INTVAL (XEXP (XEXP (note, 0), 1));
 
        found = true;
-       if (best_predictor > predictor)
+       if (best_predictor > predictor
+           && predictor_info[predictor].flags & PRED_FLAG_FIRST_MATCH)
          best_probability = probability, best_predictor = predictor;
 
        d = (combined_probability * probability
@@ -855,7 +856,7 @@ combine_predictions_for_insn (rtx_insn *insn, basic_block bb)
      use no_prediction heuristic, in case we did match, use either
      first match or Dempster-Shaffer theory depending on the flags.  */
 
-  if (predictor_info [best_predictor].flags & PRED_FLAG_FIRST_MATCH)
+  if (best_predictor != END_PREDICTORS)
     first_match = true;
 
   if (!found)
@@ -863,10 +864,12 @@ combine_predictions_for_insn (rtx_insn *insn, basic_block bb)
                     combined_probability, bb);
   else
     {
-      dump_prediction (dump_file, PRED_DS_THEORY, combined_probability,
-                      bb, !first_match ? REASON_NONE : REASON_IGNORED);
-      dump_prediction (dump_file, PRED_FIRST_MATCH, best_probability,
-                      bb, first_match ? REASON_NONE : REASON_IGNORED);
+      if (!first_match)
+       dump_prediction (dump_file, PRED_DS_THEORY, combined_probability,
+                        bb, !first_match ? REASON_NONE : REASON_IGNORED);
+      else
+       dump_prediction (dump_file, PRED_FIRST_MATCH, best_probability,
+                        bb, first_match ? REASON_NONE : REASON_IGNORED);
     }
 
   if (first_match)
@@ -1096,7 +1099,8 @@ combine_predictions_for_bb (basic_block bb, bool dry_run)
          found = true;
          /* First match heuristics would be widly confused if we predicted
             both directions.  */
-         if (best_predictor > predictor)
+         if (best_predictor > predictor
+           && predictor_info[predictor].flags & PRED_FLAG_FIRST_MATCH)
            {
               struct edge_prediction *pred2;
              int prob = probability;
@@ -1142,17 +1146,19 @@ combine_predictions_for_bb (basic_block bb, bool dry_run)
      use no_prediction heuristic, in case we did match, use either
      first match or Dempster-Shaffer theory depending on the flags.  */
 
-  if (predictor_info [best_predictor].flags & PRED_FLAG_FIRST_MATCH)
+  if (best_predictor != END_PREDICTORS)
     first_match = true;
 
   if (!found)
     dump_prediction (dump_file, PRED_NO_PREDICTION, combined_probability, bb);
   else
     {
-      dump_prediction (dump_file, PRED_DS_THEORY, combined_probability, bb,
-                      !first_match ? REASON_NONE : REASON_IGNORED);
-      dump_prediction (dump_file, PRED_FIRST_MATCH, best_probability, bb,
-                      first_match ? REASON_NONE : REASON_IGNORED);
+      if (!first_match)
+       dump_prediction (dump_file, PRED_DS_THEORY, combined_probability, bb,
+                        !first_match ? REASON_NONE : REASON_IGNORED);
+      else
+       dump_prediction (dump_file, PRED_FIRST_MATCH, best_probability, bb,
+                        first_match ? REASON_NONE : REASON_IGNORED);
     }
 
   if (first_match)