Hi,
this patch fixes similar issue in update_profile_after_ifcombine
(in Jakub's testcase the conditional is first combined and later split
again and in both cases we got update unnecesarily imprecise).

Bootstrapped/regtested x86_64-linux, comitted.

        * tree-ssa-ifcombine.c (update_profile_after_ifcombine): Handle
        profile_probability::always better.

Index: tree-ssa-ifcombine.c
===================================================================
--- tree-ssa-ifcombine.c        (revision 266450)
+++ tree-ssa-ifcombine.c        (working copy)
@@ -360,8 +360,15 @@ update_profile_after_ifcombine (basic_bl
 
   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;
 

Reply via email to