tree-ssa-ifcombine.c (update_profile_after_ifcombine): Handle profile_probability...
authorJan Hubicka <jh@suse.cz>
Wed, 28 Nov 2018 20:34:06 +0000 (21:34 +0100)
committerJan Hubicka <hubicka@gcc.gnu.org>
Wed, 28 Nov 2018 20:34:06 +0000 (20:34 +0000)
* tree-ssa-ifcombine.c (update_profile_after_ifcombine): Handle
profile_probability::always better.

From-SVN: r266585

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

index 3c1f926e239fc9532df83c72868afe3c74430cbb..bc49105e219f5107452ce4c842a16299b411a0c3 100644 (file)
@@ -1,3 +1,8 @@
+2018-11-28  Jan Hubicka  <jh@suse.cz>
+
+       * tree-ssa-ifcombine.c (update_profile_after_ifcombine): Handle
+       profile_probability::always better.
+
 2018-11-28  Jan Hubicka  <jh@suse.cz>
 
        * profile-count.h (profile_count::split): Give better result when
index b63c600c47b2972c08c8df57a6ff9ffb6ceeeae9..2b969378d6506ece0f640b05cd15894f5fb4b406 100644 (file)
@@ -360,8 +360,15 @@ update_profile_after_ifcombine (basic_block inner_cond_bb,
 
   inner_cond_bb->count = outer_cond_bb->count;
 
-  inner_taken->probability = outer2->probability + outer_to_inner->probability
-                            * inner_taken->probability;
+  /* Handle special case where inner_taken probability is always. In this case
+     we know that the overall outcome will be always as well, but combining
+     probabilities will be conservative because it does not know that
+     outer2->probability is inverse of outer_to_inner->probability.  */
+  if (inner_taken->probability == profile_probability::always ())
+    ;
+  else
+    inner_taken->probability = outer2->probability + outer_to_inner->probability
+                              * inner_taken->probability;
   inner_not_taken->probability = profile_probability::always ()
                                 - inner_taken->probability;