aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJan Hubicka <hubicka@ucw.cz>2025-05-28 14:18:39 +0200
committerJan Hubicka <hubicka@ucw.cz>2025-05-28 14:19:12 +0200
commita4dc4001999a8b504cde468618af12c9b870589b (patch)
tree83fd967c74c625ba7f5584052b21a48c7f2f31de /gcc
parent33ee574a7444b238005d89fdfdf2f21f50b1fc6e (diff)
downloadgcc-a4dc4001999a8b504cde468618af12c9b870589b.zip
gcc-a4dc4001999a8b504cde468618af12c9b870589b.tar.gz
gcc-a4dc4001999a8b504cde468618af12c9b870589b.tar.bz2
Do not recompute profile when entry block has afdo count of 0
With normal profile feedback checking entry block count to be non-zero is quite reliable check for presence of non-0 profile in the body since the function body can only be executed if the entry block was executed. With autofdo this is not true, since the entry block may just execute too few times to be recorded. As a consequence we currently drop AFDO profile quite often. This patch fixes it. gcc/ChangeLog: * predict.cc (rebuild_frequencies): look harder for presence of profile feedback.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/predict.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/gcc/predict.cc b/gcc/predict.cc
index 16dd9b0..872f54d 100644
--- a/gcc/predict.cc
+++ b/gcc/predict.cc
@@ -4444,11 +4444,14 @@ rebuild_frequencies (void)
bool inconsistency_found = false;
bool uninitialized_probablity_found = false;
bool uninitialized_count_found = false;
+ bool feedback_found = false;
cfun->cfg->count_max = profile_count::uninitialized ();
FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR_FOR_FN (cfun), NULL, next_bb)
{
cfun->cfg->count_max = cfun->cfg->count_max.max (bb->count);
+ if (bb->count.nonzero_p () && bb->count.quality () >= AFDO)
+ feedback_found = true;
/* Uninitialized count may be result of inlining or an omision in an
optimization pass. */
if (!bb->count.initialized_p ())
@@ -4516,8 +4519,7 @@ rebuild_frequencies (void)
Propagating from probabilities would make profile look consistent, but
because probablities after code duplication may not be representative
for a given run, we would only propagate the error further. */
- if (ENTRY_BLOCK_PTR_FOR_FN (cfun)->count.ipa ().nonzero_p ()
- && !uninitialized_count_found)
+ if (feedback_found && !uninitialized_count_found)
{
if (dump_file)
fprintf (dump_file,