Convert profile probabilities to new type

Alexander Monakov amonakov@ispras.ru
Fri Jun 30 18:28:00 GMT 2017


On Fri, 30 Jun 2017, Andreas Schwab wrote:

> This breaks ia64, a lot of testsuite failures like this:
> 
> FAIL: c-c++-common/torture/pr53505.c   -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions  (internal compiler error)
> FAIL: c-c++-common/torture/pr53505.c   -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions  (test for excess errors)
> Excess errors:
> during RTL pass: mach
> /usr/local/gcc/gcc-20170630/gcc/testsuite/c-c++-common/torture/pr53505.c:26:1: internal compiler error: in merge_expr, at sel-sched-ir.c:1886

The patch introduced a new inconsistency in sel-sched-ir.c:

@@ -4747,7 +4747,9 @@ compute_succs_info (insn_t insn, short flags)
           sinfo->probs_ok.safe_push (
                    /* FIXME: Improve calculation when skipping
                        inner loop to exits.  */
-                    si.bb_end ? si.e1->probability : REG_BR_PROB_BASE);
+                    si.bb_end && si.e1->probability.initialized_p ()
+                   ? si.e1->probability.to_reg_br_prob_base ()
+                   : REG_BR_PROB_BASE);
           sinfo->succs_ok_n++;
         }
       else
@@ -4756,8 +4758,8 @@ compute_succs_info (insn_t insn, short flags)
       /* Compute all_prob.  */
       if (!si.bb_end)
         sinfo->all_prob = REG_BR_PROB_BASE;
-      else
-        sinfo->all_prob += si.e1->probability;
+      else if (si.e1->probability.initialized_p ())
+        sinfo->all_prob += si.e1->probability.to_reg_br_prob_base ();

       sinfo->all_succs_n++;
     }

After the change, edges that fail the predicate contribute REG_BR_PROB_BASE in
the upper hunk, but 0 in the lower hunk. Before the change, they contributed 0
in both cases.

The following patch should restore things:

diff --git a/gcc/sel-sched-ir.c b/gcc/sel-sched-ir.c
index dd72828..fa88259 100644
--- a/gcc/sel-sched-ir.c
+++ b/gcc/sel-sched-ir.c
@@ -4747,8 +4747,10 @@ compute_succs_info (insn_t insn, short flags)
           sinfo->probs_ok.safe_push (
 		    /* FIXME: Improve calculation when skipping
                        inner loop to exits.  */
-                    si.bb_end && si.e1->probability.initialized_p ()
-		    ? si.e1->probability.to_reg_br_prob_base ()
+                    si.bb_end
+		    ? (si.e1->probability.initialized_p ()
+                       ? si.e1->probability.to_reg_br_prob_base ()
+                       : 0)
 		    : REG_BR_PROB_BASE);
           sinfo->succs_ok_n++;
         }



More information about the Gcc-patches mailing list