Skip to content

Commit c5a4512

Browse files
authored
[AMDGPU] iglp.opt does not clobber memory operands (#126976)
I think it was an accident that this wasn't included.
1 parent 92f916f commit c5a4512

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

llvm/lib/Target/AMDGPU/AMDGPUMemoryUtils.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ bool isReallyAClobber(const Value *Ptr, MemoryDef *Def, AAResults *AA) {
367367
case Intrinsic::amdgcn_wave_barrier:
368368
case Intrinsic::amdgcn_sched_barrier:
369369
case Intrinsic::amdgcn_sched_group_barrier:
370+
case Intrinsic::amdgcn_iglp_opt:
370371
return false;
371372
default:
372373
break;
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
; RUN: llc -mtriple=amdgcn -mcpu=gfx942 --stop-after=si-fix-sgpr-copies < %s | FileCheck %s
2+
3+
; iglp.opt should not be flagged as clobbering the memory operand for the global_load, and we should be able to
4+
; lower into the scalar version (i.e. should not need to lower into vector version with waterfall loop)
5+
; CHECK-NOT: WATERFALL
6+
7+
define amdgpu_kernel void @_attn_forward_fp8e5_128x32x64_BW128(ptr addrspace(1) %in, ptr addrspace(3) %out) {
8+
.lr.ph:
9+
br label %1
10+
11+
1: ; preds = %1, %.lr.ph
12+
%addr = phi ptr addrspace(1) [ null, %.lr.ph ], [ %gep, %1 ]
13+
%offset = phi i64 [ 0, %.lr.ph ], [ %nextOff, %1 ]
14+
%inc = phi i32 [0, %.lr.ph], [ %incCond, %1 ]
15+
%rsrc = tail call ptr addrspace(8) @llvm.amdgcn.make.buffer.rsrc.p1(ptr addrspace(1) %addr, i16 0, i32 0, i32 0)
16+
%load = tail call <2 x i32> @llvm.amdgcn.raw.ptr.buffer.load.v2i32(ptr addrspace(8) %rsrc, i32 0, i32 0, i32 0)
17+
%load.bc = bitcast <2 x i32> %load to <8 x i8>
18+
%load.elem = extractelement <8 x i8> %load.bc, i64 0
19+
tail call void @llvm.amdgcn.iglp.opt(i32 0)
20+
%vec = insertelement <4 x i8> zeroinitializer, i8 %load.elem, i64 0
21+
%vec.bc = bitcast <4 x i8> %vec to <2 x half>
22+
%shuff = shufflevector <2 x half> %vec.bc, <2 x half> zeroinitializer, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
23+
%gep = getelementptr i8, ptr addrspace(1) %in, i64 %offset
24+
%unmaskedload49 = load <1 x i64>, ptr addrspace(1) null, align 8
25+
%nextOff = extractelement <1 x i64> %unmaskedload49, i64 0
26+
%incCond = add i32 %inc, 1
27+
%cond = icmp eq i32 %incCond, 32
28+
br i1 %cond, label %2, label %1
29+
30+
2:
31+
store <4 x half> %shuff, ptr addrspace(3) %out, align 8
32+
ret void
33+
}
34+
35+
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
36+
declare ptr addrspace(8) @llvm.amdgcn.make.buffer.rsrc.p1(ptr addrspace(1) readnone, i16, i32, i32) #0
37+
38+
; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: read)
39+
declare <2 x i32> @llvm.amdgcn.raw.ptr.buffer.load.v2i32(ptr addrspace(8) nocapture readonly, i32, i32, i32 immarg) #1

0 commit comments

Comments
 (0)