This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

handle profile_probability::always in profile_count::split better


Hi,
this fixes (minor) profile updating issue which was uncovered by
somewhat devilish testcase Jakub accidentally created for branch
prediction code.

When expanding if (cond) goto xxx; gimple stmt with probability
profile_count::one into mutliple conditionals, we may end up predicting
whole chain with "guessed" quality which is unnecesary downgrade of
information we already have in CFG.

Bootstrapped/regtested x86_64-linux, comitted.

Honza

	* profile-count.h (profile_count::split): Give better result when
	splitting profile_probability::always.
Index: profile-count.h
===================================================================
--- profile-count.h	(revision 266450)
+++ profile-count.h	(working copy)
@@ -447,8 +447,12 @@ public:
     {
       profile_probability ret = *this * cprob;
       /* The following is equivalent to:
-         *this = cprob.invert () * *this / ret.invert ();  */
-      *this = (*this - ret) / ret.invert ();
+         *this = cprob.invert () * *this / ret.invert ();
+	 Avoid scaling when overall outcome is supposed to be always.
+	 Without knowing that one is inverse of toher, the result would be
+	 conservative.  */
+      if (!(*this == profile_probability::always ()))
+        *this = (*this - ret) / ret.invert ();
       return ret;
     }
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]