[llvm] [AMDGPU] Fix poison result on inttoptr a narrow integer to ptr addrspace(7) in LowerBufferFatPointers (PR #216966)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 18 02:32:32 PDT 2026
================
@@ -2224,10 +2224,17 @@ PtrParts SplitPtrStructs::visitIntToPtrInst(IntToPtrInst &IP) {
auto *RetTy = cast<StructType>(IP.getType());
Type *RsrcTy = RetTy->getElementType(0);
Type *OffTy = RetTy->getElementType(1);
- Value *RsrcPart = IRB.CreateLShr(
- Int,
- ConstantExpr::getIntegerValue(IntTy, APInt(Width, BufferOffsetWidth)));
- Value *RsrcInt = IRB.CreateIntCast(RsrcPart, RsrcIntTy, /*isSigned=*/false);
+ // inttoptr zero-extends, so narrow inputs contribute nothing to the resource
+ // part.
+ Value *RsrcInt;
+ if (Width <= BufferOffsetWidth) {
+ RsrcInt = Constant::getNullValue(RsrcIntTy);
+ } else {
+ Value *RsrcPart = IRB.CreateLShr(
+ Int,
+ ConstantExpr::getIntegerValue(IntTy, APInt(Width, BufferOffsetWidth)));
----------------
arsenm wrote:
Not sure why this is using ConstantExpr::
https://github.com/llvm/llvm-project/pull/216966
More information about the llvm-commits
mailing list