[llvm] [InferAddressSpaces] Handle unconverted ptrmask (PR #140802)
Robert Imschweiler via llvm-commits
llvm-commits at lists.llvm.org
Thu May 22 13:56:43 PDT 2025
================
@@ -669,17 +666,51 @@ Value *InferAddressSpacesImpl::cloneInstructionWithNewAddressSpace(
// Technically the intrinsic ID is a pointer typed argument, so specially
// handle calls early.
assert(II->getIntrinsicID() == Intrinsic::ptrmask);
- Value *NewPtr = operandWithNewAddressSpaceOrCreatePoison(
- II->getArgOperandUse(0), NewAddrSpace, ValueWithNewAddrSpace,
- PredicatedAS, PoisonUsesToFix);
- Value *Rewrite =
- TTI->rewriteIntrinsicWithAddressSpace(II, II->getArgOperand(0), NewPtr);
- if (Rewrite) {
- assert(Rewrite != II && "cannot modify this pointer operation in place");
- return Rewrite;
+ const Use &PtrOpUse = II->getArgOperandUse(0);
+ unsigned OldAddrSpace = PtrOpUse.get()->getType()->getPointerAddressSpace();
+ Value *MaskOp = II->getArgOperand(1);
+ Type *MaskTy = MaskOp->getType();
+
+ bool DoTruncate = false;
+ bool DoNotConvert = false;
+
+ if (!TTI->isNoopAddrSpaceCast(OldAddrSpace, NewAddrSpace)) {
+ // All valid 64-bit to 32-bit casts work by chopping off the high
+ // bits. Any masking only clearing the low bits will also apply in the new
+ // address space.
+ if (DL->getPointerSizeInBits(OldAddrSpace) != 64 ||
+ DL->getPointerSizeInBits(NewAddrSpace) != 32) {
----------------
ro-i wrote:
https://github.com/llvm/llvm-project/blob/23f0fbf8fff563c77f770f83096b522c3c99a82d/llvm/lib/Target/AMDGPU/AMDGPU.h#L561
seems to suggest that, too, I think. This function is called by isValidAddrSpaceCast in AMDGPUTargetTransformInfo:
https://github.com/llvm/llvm-project/blob/23f0fbf8fff563c77f770f83096b522c3c99a82d/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.h#L180-L187
https://github.com/llvm/llvm-project/pull/140802
More information about the llvm-commits
mailing list