profile.c (compute_branch_probabilities): Use REG_BR_PROB notes when re-constructing...
authorJan Hubicka <jh@suse.cz>
Sat, 25 Sep 2004 23:21:07 +0000 (01:21 +0200)
committerJan Hubicka <hubicka@gcc.gnu.org>
Sat, 25 Sep 2004 23:21:07 +0000 (23:21 +0000)
* profile.c (compute_branch_probabilities): Use REG_BR_PROB notes
when re-constructing profile previously invalidated by loop.

From-SVN: r88115

gcc/ChangeLog
gcc/profile.c

index 0ba761ff869cf00e2ce077579dc31676622ebd46..7cd05ada7477b2743f4830df42d347d91557f11c 100644 (file)
@@ -1,3 +1,8 @@
+2004-09-26  Jan Hubicka  <jh@suse.cz>
+
+       * profile.c (compute_branch_probabilities): Use REG_BR_PROB notes
+       when re-constructing profile previously invalidated by loop.
+
 2004-09-25  Dale Johannesen  <dalej@apple.com>
 
        * tree-gimple.c:  Move GIMPLE definition...
index 3f48be623d2d494bac5b600dd414facdf5d79797..39d0493c6dd91dd417f656e996e081e9ea7bd7f3 100644 (file)
@@ -557,12 +557,24 @@ compute_branch_probabilities (void)
              num_branches++;
            }
        }
-      /* Otherwise distribute the probabilities evenly so we get sane
-        sum.  Use simple heuristics that if there are normal edges,
+      /* Otherwise try to preserve the existing REG_BR_PROB probabilities
+         tree based profile guessing put into code.  */
+      else if (profile_status == PROFILE_ABSENT
+              && !ir_type ()
+              && bb->succ && bb->succ->succ_next
+              && (note = find_reg_note (BB_END (bb), REG_BR_PROB, 0)))
+       {
+         int prob = INTVAL (XEXP (note, 0));
+
+         BRANCH_EDGE (bb)->probability = prob;
+         FALLTHRU_EDGE (bb)->probability = REG_BR_PROB_BASE - prob;
+       }
+      /* As a last resolt, distribute the probabilities evenly.
+        Use simple heuristics that if there are normal edges,
         give all abnormals frequency of 0, otherwise distribute the
         frequency over abnormals (this is the case of noreturn
         calls).  */
-      else
+      else if (profile_status == PROFILE_ABSENT)
        {
          int total = 0;