[llvm] [InferAddressSpaces] Do not commute ptrmask with cast when it may not preserve null (PR #219472)

Robert Imschweiler via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 14 05:25:50 PDT 2026


================
@@ -827,17 +827,16 @@ Value *InferAddressSpacesImpl::clonePtrMaskWithNewAddressSpace(
 
   KnownBits OldPtrBits{DL->getPointerSizeInBits(OldAddrSpace)};
   KnownBits NewPtrBits{DL->getPointerSizeInBits(NewAddrSpace)};
-  if (!TTI->isNoopAddrSpaceCast(OldAddrSpace, NewAddrSpace)) {
+  bool IsNoopCast = TTI->isNoopAddrSpaceCast(OldAddrSpace, NewAddrSpace);
+  if (!IsNoopCast) {
     std::tie(OldPtrBits, NewPtrBits) =
         TTI->computeKnownBitsAddrSpaceCast(NewAddrSpace, *PtrOpUse.get());
----------------
ro-i wrote:

shouldn't the heavy lifting happen here? Since that's where I baked in the null=0 assumption back then (as we didn't have other information - darker times 😔 )

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


More information about the llvm-commits mailing list