[PATCH] D37940: Peel off the dominant case in switch statement

Hans Wennborg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 15 15:56:36 PDT 2017


hans added inline comments.


================
Comment at: lib/Transforms/Utils/SimplifyCFG.cpp:5680
 
+  if (PeelDominantCase(SI, Builder))
+    return SimplifyCFG(BB, TTI, BonusInstThreshold, AC) | true;
----------------
I don't think we should do this if SwitchToLookupTable (the call below) can turn the swich into a lookup instead.

In fact, I don't think this should be done at the IR level at all, since it's more of a switch lowering issue. SelectionDAGBuilder::visitSwitch() would be a better place.

That code already takes case weights into account, and when lowering to a binary search tree, it will balance it based on weight, favoring cases that are hot. Do you find that that's not sufficient? (I'm willing to believe that's the case, but I'd like to see it argued.)


https://reviews.llvm.org/D37940





More information about the llvm-commits mailing list