[llvm] [SimplifyCFG] Add optimization for switches of powers of two (PR #70977)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 15 03:25:23 PST 2023


================
@@ -6839,6 +6837,80 @@ static bool ReduceSwitchRange(SwitchInst *SI, IRBuilder<> &Builder,
   return true;
 }
 
+static bool simplifySwitchOfPowersOfTwo(SwitchInst *SI, IRBuilder<> &Builder,
+                                        const DataLayout &DL,
+                                        const TargetTransformInfo &TTI) {
+
+  auto *Condition = SI->getCondition();
+  auto &Context = SI->getContext();
----------------
nikic wrote:

```suggestion
  Value *Condition = SI->getCondition();
  LLVMContext &Context = SI->getContext();
```

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


More information about the llvm-commits mailing list