[PATCH] LowerSwitch: replace unreachable default with popular case destination
hans at chromium.org
Thu Jan 15 21:41:40 PST 2015
Ah, I see what you mean. I didn't notice that the code was exploiting that.
I guess we could try to come up with a heuristic for when replacing the unreachable default is profitable even though we can't exploit the unreachable gaps. For example, if we can remove half or more of the case clusters, it's probably profitable.
I'm not sure how to proceed here though. My patch is really just preserving current functionality, but moving it out of SimplifyCFG (and now with the bonus of allowing this code to set Lower/UpperBound.)
If you think it's better for LowerSwitch to not do this transformation, I'm fine with that too. Or we could try to come up with a heuristic for when it's more profitable than exploiting the unreachable gaps.
More information about the llvm-commits