Skip to content

Commit dcec930

Browse files
AMDGPU: Fix inst-selection of large scratch offsets with sgpr base
Use i32 for offset instead of i16, this way it does not get interpreted as negative 16 bit offset.
1 parent 41189ad commit dcec930

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1911,7 +1911,7 @@ bool AMDGPUDAGToDAGISel::SelectScratchSAddr(SDNode *Parent, SDValue Addr,
19111911
0);
19121912
}
19131913

1914-
Offset = CurDAG->getTargetConstant(COffsetVal, DL, MVT::i16);
1914+
Offset = CurDAG->getTargetConstant(COffsetVal, DL, MVT::i32);
19151915

19161916
return true;
19171917
}

llvm/test/CodeGen/AMDGPU/flat-scratch.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4926,7 +4926,7 @@ define amdgpu_gs void @sgpr_base_large_offset(ptr addrspace(1) %out, ptr addrspa
49264926
;
49274927
; GFX12-LABEL: sgpr_base_large_offset:
49284928
; GFX12: ; %bb.0: ; %entry
4929-
; GFX12-NEXT: scratch_load_b32 v2, off, s0 offset:-24
4929+
; GFX12-NEXT: scratch_load_b32 v2, off, s0 offset:65512
49304930
; GFX12-NEXT: s_wait_loadcnt 0x0
49314931
; GFX12-NEXT: global_store_b32 v[0:1], v2, off
49324932
; GFX12-NEXT: s_nop 0
@@ -4985,7 +4985,7 @@ define amdgpu_gs void @sgpr_base_large_offset(ptr addrspace(1) %out, ptr addrspa
49854985
;
49864986
; GFX12-PAL-LABEL: sgpr_base_large_offset:
49874987
; GFX12-PAL: ; %bb.0: ; %entry
4988-
; GFX12-PAL-NEXT: scratch_load_b32 v2, off, s0 offset:-24
4988+
; GFX12-PAL-NEXT: scratch_load_b32 v2, off, s0 offset:65512
49894989
; GFX12-PAL-NEXT: s_wait_loadcnt 0x0
49904990
; GFX12-PAL-NEXT: global_store_b32 v[0:1], v2, off
49914991
; GFX12-PAL-NEXT: s_nop 0

0 commit comments

Comments
 (0)