[llvm] [SimplifyCFG] Delete the unnecessary range check for small mask operation (PR #65835)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 17 06:15:41 PDT 2023
================
@@ -6545,6 +6544,17 @@ static bool SwitchToLookupTable(SwitchInst *SI, IRBuilder<> &Builder,
BranchInst *RangeCheckBranch = nullptr;
+ if (UseSwitchConditionAsTableIndex) {
+ ConstantRange CR = computeConstantRange(TableIndex, /* ForSigned */ false);
+ if (DL.fitsInLegalInteger(CR.getUpper().getLimitedValue())) {
----------------
zmodem wrote:
Why is `fitsInLegalInteger` the right check? For example, if the index is `x % 128` and we have 125 cases, shouldn't we want to grow the table to 127?
Also, since we're trading size for speed, maybe we should not do this in `optsize` functions?
https://github.com/llvm/llvm-project/pull/65835
More information about the llvm-commits
mailing list