tree-ssa-threadupdate.c (freqs_to_counts_path): Scale frequencies up when synthesizin...
authorTeresa Johnson <tejohnson@google.com>
Fri, 3 Oct 2014 00:46:16 +0000 (00:46 +0000)
committerTeresa Johnson <tejohnson@gcc.gnu.org>
Fri, 3 Oct 2014 00:46:16 +0000 (00:46 +0000)
2014-10-02  Teresa Johnson  <tejohnson@google.com>

* tree-ssa-threadupdate.c (freqs_to_counts_path): Scale frequencies
up when synthesizing counts to avoid rounding errors.

From-SVN: r215830

gcc/ChangeLog
gcc/tree-ssa-threadupdate.c

index bbdef99c7e1e26ba9edd526010f53d35a9d44453..75dd0b5ceacc467d5be1e12658b167ffa819413e 100644 (file)
@@ -1,3 +1,8 @@
+2014-10-02  Teresa Johnson  <tejohnson@google.com>
+
+       * tree-ssa-threadupdate.c (freqs_to_counts_path): Scale frequencies
+       up when synthesizing counts to avoid rounding errors.
+
 2014-10-02  Teresa Johnson  <tejohnson@google.com>
 
        PR middle-end/63422
index e3e77cf25586287b60c16c87b5c412211ecd0dc5..d660fdba6a9906fa7ae592412a246ecf60da2810 100644 (file)
@@ -977,15 +977,25 @@ freqs_to_counts_path (struct redirection_data *rd)
   edge ein;
   edge_iterator ei;
   FOR_EACH_EDGE (ein, ei, e->dest->preds)
-    ein->count = EDGE_FREQUENCY (ein);
+    {
+      /* Scale up the frequency by REG_BR_PROB_BASE, to avoid rounding
+         errors applying the probability when the frequencies are very
+         small.  */
+      ein->count = apply_probability (ein->src->frequency * REG_BR_PROB_BASE,
+                                      ein->probability);
+    }
 
   for (unsigned int i = 1; i < path->length (); i++)
     {
       edge epath = (*path)[i]->e;
       edge esucc;
+      /* Scale up the frequency by REG_BR_PROB_BASE, to avoid rounding
+         errors applying the edge probability when the frequencies are very
+         small.  */
+      epath->src->count = epath->src->frequency * REG_BR_PROB_BASE;
       FOR_EACH_EDGE (esucc, ei, epath->src->succs)
-        esucc->count = EDGE_FREQUENCY (esucc);
-      epath->src->count = epath->src->frequency;
+        esucc->count = apply_probability (esucc->src->count,
+                                          esucc->probability);
     }
 }