[PATCH] [PGO] Hoist hot case statement from switches

Hans Wennborg hans at chromium.org
Mon Mar 30 10:37:08 PDT 2015


I too am a little concerned about the approach of peeling off a hot case. Like djasper pointed out, it might have been possible to include the case in a jump table (even worse, peeling the case might prevent a jump table being built due to density changing). More generally, peeling a hot case will penalize the non-hot cases by putting an extra branch in front of them, which means we'd only want to do this when the hot case is completely dominating.

If we do want to peel a hot case, my patch would allow doing that without disrupting jump tables or bit tests: we'd extract those first, and then peel the hot CaseCluster, which might be a single case, range, jump table or bit test.

The direction I'd like to explore with my patch however, is to balance the binary tree based on profile info rather than node count. That would put hotter cases closer to the root. If f(x) is the number of branches needed to reach case x, I think this approach would minimize the expected value of f(x) when x is a random variable with a distribution matching the profile info.


http://reviews.llvm.org/D5786

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list