[llvm] [SimplifyCFG] Lay switch lookup tables out over the narrower of the signed and unsigned case range (PR #221489)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 12 08:07:00 PDT 2026


================
@@ -7686,17 +7725,23 @@ static bool simplifySwitchLookup(SwitchInst *SI, IRBuilder<> &Builder,
   // TableIndex is the switch condition - TableIndexOffset if we don't
   // use the condition directly
   if (!UseSwitchConditionAsTableIndex) {
-    // If the default is unreachable, all case values are s>= MinCaseVal. Then
-    // we can try to attach nsw.
-    bool MayWrap = true;
+    bool HasNUW = false;
----------------
dtcxzyw wrote:

Setting `nuw` for `sub X, C` doesn't work because a later InstCombine run converts it to `add X, -C`, and the flag isn't propagated.


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


More information about the llvm-commits mailing list