[llvm] [RFC][Transforms] Prefer unreachable insn over optimizaiton with undef (PR #131020)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 12 13:26:49 PDT 2025


================
@@ -4829,9 +4829,9 @@ static Value *simplifySelectInst(Value *Cond, Value *TrueVal, Value *FalseVal,
     if (isa<PoisonValue>(CondC))
       return PoisonValue::get(TrueVal->getType());
 
-    // select undef, X, Y -> X or Y
+    // select undef, X, Y -> undef
     if (Q.isUndefValue(CondC))
-      return isa<Constant>(FalseVal) ? FalseVal : TrueVal;
+      return UndefValue::get(TrueVal->getType());
----------------
nikic wrote:

This is incorrect. The result of the select must be one of X or Y.

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


More information about the llvm-commits mailing list