[llvm] [SimplifyCFG]: Switch on umin replaces default (PR #164097)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 18 09:56:03 PDT 2025
================
@@ -7540,6 +7540,62 @@ static bool reduceSwitchRange(SwitchInst *SI, IRBuilder<> &Builder,
return true;
}
+/// Tries to transform the switch when the condition is umin and a constant.
+/// In that case, the default branch can be replaced by the constant's branch.
+/// For example:
+/// switch(umin(a, 3)) {
+/// case 0:
+/// case 1:
+/// case 2:
+/// case 3:
+/// // ...
+/// default:
+/// unreachable
+/// }
+///
+/// Transforms into:
+///
+/// switch(umin(a, 3)) {
----------------
dtcxzyw wrote:
```suggestion
/// switch(a) {
```
https://github.com/llvm/llvm-project/pull/164097
More information about the llvm-commits
mailing list