[llvm] [SimplifyCFG] Delete the unnecessary range check for small mask operation (PR #65835)

via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 19 07:35:56 PDT 2023


================
@@ -6545,6 +6544,19 @@ static bool SwitchToLookupTable(SwitchInst *SI, IRBuilder<> &Builder,
 
   BranchInst *RangeCheckBranch = nullptr;
 
+  // Grow the table to cover all possible index values to avoid the range check.
+  if (UseSwitchConditionAsTableIndex) {
+    ConstantRange CR = computeConstantRange(TableIndex, /* ForSigned */ false);
+    if (SwitchLookupTable::WouldFitInRegister(
----------------
vfdff wrote:

Apply your comment, thanks

https://github.com/llvm/llvm-project/pull/65835


More information about the llvm-commits mailing list