[llvm] [SimplifyCFG] Fold switch over ucmp/scmp to icmp and br (PR #105636)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 22 03:20:22 PDT 2024
================
@@ -7131,6 +7131,59 @@ static bool simplifySwitchOfPowersOfTwo(SwitchInst *SI, IRBuilder<> &Builder,
return true;
}
+/// Fold switch over ucmp/scmp intrinsic to br if two of the switch arms have
+/// the same destination.
+static bool simplifySwitchOfCmpIntrinsic(SwitchInst *SI,
+ IRBuilderBase &Builder) {
+ auto *Cmp = dyn_cast<CmpIntrinsic>(SI->getCondition());
+ if (!Cmp || !Cmp->hasOneUse() || SI->getNumCases() != 2)
----------------
dtcxzyw wrote:
We should handle the following case:
```
switch i8 %cond, label %default.unreachable [
i8 -1, label %bb1
i8 0, label %bb1
i8 1, label %bb2
]
```
https://github.com/llvm/llvm-project/pull/105636
More information about the llvm-commits
mailing list