[llvm] [SimplifyCFG]: Switch on umin replaces default (PR #164097)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 19 09:22:51 PDT 2025
================
@@ -7540,6 +7540,60 @@ 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:
----------------
nikic wrote:
I think this needs to be explicitly checked in the transform, we shouldn't rely on eliminateDeadSwitchCases having removed such cases (looking at the implementation, it uses known bits rather than ranges, so I think it may not eliminate all dead cases if the umin is not at a power of two boundary).
https://github.com/llvm/llvm-project/pull/164097
More information about the llvm-commits
mailing list