]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix profile update in tree-ssa-loop-im.cc
authorJan Hubicka <jh@suse.cz>
Thu, 27 Jul 2023 13:58:52 +0000 (15:58 +0200)
committerJan Hubicka <jh@suse.cz>
Thu, 27 Jul 2023 13:58:52 +0000 (15:58 +0200)
This fixes two bugs in tree-ssa-loop-im.cc.  First is that cap probability is not
reliable, but it is constructed with adjusted quality.  Second is that sometimes
the conditional has wrong joiner BB count.  This is visible on
testsuite/gcc.dg/pr102385.c however the testcase triggers another profile
update bug in pcom, so I will update it in followup patch.

gcc/ChangeLog:

* tree-ssa-loop-im.cc (execute_sm_if_changed): Turn cap probability
to guessed; fix count of new_bb.

gcc/tree-ssa-loop-im.cc

index f5b01e986aeb283f22c568642ace052ceb12579c..268f466bdc9f547525763ef9748c9aae58195cd5 100644 (file)
@@ -2059,7 +2059,8 @@ execute_sm_if_changed (edge ex, tree mem, tree tmp_var, tree flag,
        nbbs++;
     }
 
-  profile_probability cap = profile_probability::always ().apply_scale (2, 3);
+  profile_probability cap
+         = profile_probability::guessed_always ().apply_scale (2, 3);
 
   if (flag_probability.initialized_p ())
     ;
@@ -2103,6 +2104,8 @@ execute_sm_if_changed (edge ex, tree mem, tree tmp_var, tree flag,
 
   old_dest = ex->dest;
   new_bb = split_edge (ex);
+  if (append_cond_position)
+    new_bb->count += last_cond_fallthru->count ();
   then_bb = create_empty_bb (new_bb);
   then_bb->count = new_bb->count.apply_probability (flag_probability);
   if (irr)