[PATCH] D21291: [SimplifyCFG] Range reduce switches
Eli Friedman via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 13 13:26:08 PDT 2016
eli.friedman added a subscriber: eli.friedman.
eli.friedman added a comment.
Maybe it makes sense to perform this sort of transformation in SelectionDAGBuilder::visitSwitch instead? Most of the relevant logic is there.
This patch only handles situations where all the values form a linear series, but it seems important to also catch cases where *most* of the values form a linear series (for example, 97, 105, 109, 113, 117, 121).
I think your profitability model is a bit off: we never generate a jump table for less than four cases, so trying to improve the density of a nonexistent jump table seems like a bad idea. And for cases where the divisor is small, the tradeoff between extra jump table entries and an extra compare+branch isn't obvious.
Repository:
rL LLVM
http://reviews.llvm.org/D21291
More information about the llvm-commits
mailing list