diff mbox series

handle profile_probability::always better in tree-ssa-ifcombine

Message ID 20181128203337.64h5rkw7ztcotqep@kam.mff.cuni.cz
State New
Headers show
Series handle profile_probability::always better in tree-ssa-ifcombine | expand

Commit Message

Jan Hubicka Nov. 28, 2018, 8:33 p.m. UTC
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.
diff mbox series

Patch

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;