[llvm] InstSimplify: Fold nonnull addrspacecast of null to poison (PR #217905)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 3 05:00:32 PDT 2026


================
@@ -5707,6 +5707,22 @@ Value *llvm::simplifyCastInst(unsigned CastOpc, Value *Op, Type *Ty,
   return ::simplifyCastInst(CastOpc, Op, Ty, Q, RecursionLimit);
 }
 
+static Value *simplifyAddrSpaceCastInst(Value *Op, Type *Ty, bool IsNonNull,
+                                        const SimplifyQuery &Q,
+                                        unsigned MaxRecurse) {
+  if (IsNonNull && match(Op, m_Zero()) && Q.CxtI &&
+      !NullPointerIsDefined(Q.CxtI->getFunction(),
+                            Op->getType()->getPointerAddressSpace()))
----------------
arsenm wrote:

Yes. This is the default address space check, which is the only place we can make the 0 bit value assumption, which the null_pointer_is_valid takes away.

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


More information about the llvm-commits mailing list