[llvm] [InferAddressSpaces] Handle unconverted ptrmask (PR #140802)
Robert Imschweiler via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 26 04:49:35 PDT 2025
================
@@ -151,6 +152,54 @@ class TargetTransformInfoImplBase {
}
virtual bool isNoopAddrSpaceCast(unsigned, unsigned) const { return false; }
+
+ // Given an address space cast of the given pointer value, calculate the known
+ // bits of the source pointer in the source addrspace and the destination
+ // pointer in the destination addrspace.
+ virtual std::pair<KnownBits, KnownBits>
+ computeKnownBitsAddrSpaceCast(unsigned FromAS, unsigned ToAS,
+ const Value &PtrOp) const {
+ if (DL.isNonIntegralAddressSpace(FromAS))
+ return std::pair(KnownBits(DL.getPointerSizeInBits(FromAS)),
+ KnownBits(DL.getPointerSizeInBits(ToAS)));
+
+ KnownBits FromPtrBits;
+ if (const AddrSpaceCastInst *CastI = dyn_cast<AddrSpaceCastInst>(&PtrOp)) {
+ std::pair<KnownBits, KnownBits> KB = computeKnownBitsAddrSpaceCast(
+ CastI->getSrcAddressSpace(), CastI->getDestAddressSpace(),
+ *CastI->getPointerOperand());
+ FromPtrBits = KB.second;
+ } else if (isa<ConstantPointerNull>(PtrOp) && FromAS == 0) {
----------------
ro-i wrote:
`isNullValue` is not directly callable on `PtrOp`, but I think I implemented what you meant
https://github.com/llvm/llvm-project/pull/140802
More information about the llvm-commits
mailing list