Skip to content

Commit b1ace8a

Browse files
author
git apple-llvm automerger
committed
Merge commit '13c467b2cdc0' from llvm.org/main into next
2 parents 5bc33de + 13c467b commit b1ace8a

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,6 +1044,7 @@ bool GCNTTIImpl::collectFlatAddressOperands(SmallVectorImpl<int> &OpIndexes,
10441044
case Intrinsic::amdgcn_flat_atomic_fmax_num:
10451045
case Intrinsic::amdgcn_flat_atomic_fmin_num:
10461046
case Intrinsic::amdgcn_load_to_lds:
1047+
case Intrinsic::amdgcn_make_buffer_rsrc:
10471048
OpIndexes.push_back(0);
10481049
return true;
10491050
default:
@@ -1124,6 +1125,16 @@ Value *GCNTTIImpl::rewriteIntrinsicWithAddressSpace(IntrinsicInst *II,
11241125
II->setCalledFunction(NewDecl);
11251126
return II;
11261127
}
1128+
case Intrinsic::amdgcn_make_buffer_rsrc: {
1129+
Type *SrcTy = NewV->getType();
1130+
Type *DstTy = II->getType();
1131+
Module *M = II->getModule();
1132+
Function *NewDecl = Intrinsic::getOrInsertDeclaration(
1133+
M, II->getIntrinsicID(), {DstTy, SrcTy});
1134+
II->setArgOperand(0, NewV);
1135+
II->setCalledFunction(NewDecl);
1136+
return II;
1137+
}
11271138
default:
11281139
return nullptr;
11291140
}

llvm/test/Transforms/InferAddressSpaces/AMDGPU/mem-intrinsics.ll

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,13 +192,29 @@ define amdgpu_kernel void @load_to_lds_fat_pointer_as_flat(ptr addrspace(7) %buf
192192
ret void
193193
}
194194

195+
define amdgpu_kernel void @make_buffer_rsrc_global_as_flat(ptr addrspace(1) %global, i32 %extent) {
196+
;; NOTE: flags value not representative of real input
197+
; CHECK-LABEL: define amdgpu_kernel void @make_buffer_rsrc_global_as_flat(
198+
; CHECK-SAME: ptr addrspace(1) [[GLOBAL:%.*]], i32 [[EXTENT:%.*]]) {
199+
; CHECK-NEXT: [[BUFFER_FAT_PTR:%.*]] = call ptr addrspace(7) @llvm.amdgcn.make.buffer.rsrc.p7.p1(ptr addrspace(1) [[GLOBAL]], i16 0, i32 [[EXTENT]], i32 0)
200+
; CHECK-NEXT: store i32 [[EXTENT]], ptr addrspace(7) [[BUFFER_FAT_PTR]], align 4
201+
; CHECK-NEXT: ret void
202+
;
203+
%cast = addrspacecast ptr addrspace(1) %global to ptr
204+
%buffer.fat.ptr = call ptr addrspace(7) @llvm.amdgcn.make.buffer.rsrc.p7.p0(ptr %cast, i16 0, i32 %extent, i32 0)
205+
store i32 %extent, ptr addrspace(7) %buffer.fat.ptr
206+
ret void
207+
}
208+
195209
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1) #1
196210
declare void @llvm.memcpy.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i1) #1
197211
declare void @llvm.memcpy.inline.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i1) #1
198212
declare void @llvm.memcpy.p0.p3.i32(ptr nocapture writeonly, ptr addrspace(3) nocapture readonly, i32, i1) #1
199213
declare void @llvm.memmove.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i1) #1
200214
declare void @llvm.amdgcn.load.to.lds.p0(ptr nocapture readonly, ptr addrspace(3) nocapture writeonly, i32 immarg, i32 immarg, i32 immarg) #1
201215

216+
declare ptr addrspace(7) @llvm.amdgcn.make.buffer.rsrc.p7.p0(ptr readnone, i16, i32, i32) #0
217+
202218
attributes #0 = { nounwind }
203219
attributes #1 = { argmemonly nounwind }
204220

0 commit comments

Comments
 (0)