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

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 30 06:55:08 PDT 2023


================
@@ -6631,6 +6630,27 @@ static bool SwitchToLookupTable(SwitchInst *SI, IRBuilder<> &Builder,
 
   BranchInst *RangeCheckBranch = nullptr;
 
+  // Grow the table to cover all possible index values to avoid the range check.
+  // It will use the default result to fill in the table hole later, so make
+  // sure it exist.
+  if (UseSwitchConditionAsTableIndex && HasDefaultResults) {
----------------
nikic wrote:

To clarify: If the default is already not reachable, then there is no point in increasing the table size in the first place, as no branch will be generated.

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


More information about the llvm-commits mailing list