aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilip Kastl <filip.kastl@gmail.com>2023-07-05 17:36:02 +0200
committerFilip Kastl <filip.kastl@gmail.com>2023-07-05 17:36:02 +0200
commit1ee710027d8aa16145dab623815d9f9921cf9633 (patch)
tree46d25a8cdad22c0ca6281668435317342ecf6a35
parenta4778dbd935d4e26b41e5c0e6191b7311457b239 (diff)
downloadgcc-1ee710027d8aa16145dab623815d9f9921cf9633.zip
gcc-1ee710027d8aa16145dab623815d9f9921cf9633.tar.gz
gcc-1ee710027d8aa16145dab623815d9f9921cf9633.tar.bz2
value-prof.cc: Correct edge prob calculation.
The mod-subtract optimization with ncounts==1 produced incorrect edge probabilities due to incorrect conditional probability calculation. This patch fixes the calculation. Signed-off-by: Filip Kastl <filip.kastl@gmail.com> gcc/ChangeLog: * value-prof.cc (gimple_mod_subtract_transform): Correct edge prob calculation.
-rw-r--r--gcc/value-prof.cc6
1 files changed, 5 insertions, 1 deletions
diff --git a/gcc/value-prof.cc b/gcc/value-prof.cc
index f40e58a..5033a6f 100644
--- a/gcc/value-prof.cc
+++ b/gcc/value-prof.cc
@@ -1186,7 +1186,11 @@ gimple_mod_subtract_transform (gimple_stmt_iterator *si)
if (all > 0)
{
prob1 = profile_probability::probability_in_gcov_type (count1, all);
- prob2 = profile_probability::probability_in_gcov_type (count2, all);
+ if (all == count1)
+ prob2 = profile_probability::even ();
+ else
+ prob2 = profile_probability::probability_in_gcov_type (count2, all
+ - count1);
}
else
{