[llvm] [SimplifyCFG] Ensure selects have not been constant folded in `foldSwitchToSelect` (PR #161153)

Antonio Frighetto via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 29 04:09:05 PDT 2025


================
@@ -755,6 +755,25 @@ bb3:
   ret i1 %phi
 }
 
+define i32 @negative_constfold_select() {
+; CHECK-LABEL: @negative_constfold_select(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    ret i32 poison
+;
+entry:
+  switch i32 poison, label %default [
----------------
antoniofrighetto wrote:

IR before InstCombine: https://llvm.godbolt.org/z/PjdT7fj11. Tried removing immediate UB by still making the Builder return a constant value while handling a constant condition (switch on a previously-assumed equal zero value; store 0 to ptr, load back the value), but having a hard time hitting that code path w/o switching on poison. Maybe I'm missing something?

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


More information about the llvm-commits mailing list