[llvm] [SimplifyCFG] Added optimization for switches of powers of two (PR #70977)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 1 22:46:53 PDT 2023
================
@@ -6839,6 +6837,66 @@ static bool ReduceSwitchRange(SwitchInst *SI, IRBuilder<> &Builder,
return true;
}
+static bool isSwitchOfPowersOfTwo(ArrayRef<int64_t> Values) {
+ for (auto &Value : Values) {
+ if (Value <= 0 || (Value & (Value - 1)) != 0)
----------------
dtcxzyw wrote:
```suggestion
if (!llvm::has_single_bit(Value))
```
https://github.com/llvm/llvm-project/pull/70977
More information about the llvm-commits
mailing list