[llvm] [SimplifyCFG] Eliminate dead edges of switches according to the domain of conditions (PR #165748)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 14 06:52:44 PST 2025


================
@@ -6039,15 +6041,18 @@ static bool eliminateDeadSwitchCases(SwitchInst *SI, DomTreeUpdater *DTU,
         UniqueSuccessors.push_back(Successor);
       ++It->second;
     }
-    const APInt &CaseVal = Case.getCaseValue()->getValue();
+    ConstantInt *CaseC = Case.getCaseValue();
+    const APInt &CaseVal = CaseC->getValue();
     if (Known.Zero.intersects(CaseVal) || !Known.One.isSubsetOf(CaseVal) ||
-        (CaseVal.getSignificantBits() > MaxSignificantBitsInCond)) {
-      DeadCases.push_back(Case.getCaseValue());
+        (CaseVal.getSignificantBits() > MaxSignificantBitsInCond) ||
+        (IsKnownValuesValid && !KnownValues.contains(CaseC))) {
----------------
dtcxzyw wrote:

@henrickarlsson @bjope  Thanks for the report. I will take a look.

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


More information about the llvm-commits mailing list