[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:35:47 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())) {
----------------
vfdff wrote:
Thanks @zmodem for your suggesions.
I think a const value which can be fit in a general register, it is cheep. otherwise, we may need more than 1 instruction to generate a big const value. `This restriction remains consistent with GCC`.
ok, I'll check the flag `optsize`
https://github.com/llvm/llvm-project/pull/65835
More information about the llvm-commits
mailing list