-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[AMDGPU] Fix crash due to missing check for FLAT instructions that dont use vector registers when computing VALU hazard. #123627
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: llc -mtriple=amdgcn -mcpu=gfx942 < %s | FileCheck -check-prefix=GFX942 %s | ||
; RUN: llc -mtriple=amdgcn -mcpu=gfx90a -O0 < %s | FileCheck -check-prefix=GFX90A %s | ||
|
||
@G = addrspace(1) global <2 x i32> splat (i32 5) | ||
|
||
define amdgpu_ps void @global_load_lds_dword_saddr(ptr addrspace(1) inreg nocapture %gptr, ptr addrspace(3) nocapture %lptr) { | ||
; GFX942-LABEL: global_load_lds_dword_saddr: | ||
; GFX942: ; %bb.0: ; %main_body | ||
; GFX942-NEXT: v_readfirstlane_b32 s2, v0 | ||
; GFX942-NEXT: v_mov_b32_e32 v2, 0 | ||
; GFX942-NEXT: s_mov_b32 m0, s2 | ||
; GFX942-NEXT: s_nop 0 | ||
; GFX942-NEXT: global_load_lds_dword v2, s[0:1] offset:32 nt | ||
; GFX942-NEXT: s_getpc_b64 s[0:1] | ||
; GFX942-NEXT: s_add_u32 s0, s0, G@gotpcrel32@lo+4 | ||
; GFX942-NEXT: s_addc_u32 s1, s1, G@gotpcrel32@hi+12 | ||
; GFX942-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x0 | ||
; GFX942-NEXT: s_waitcnt lgkmcnt(0) | ||
; GFX942-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0 | ||
; GFX942-NEXT: s_waitcnt lgkmcnt(0) | ||
; GFX942-NEXT: s_mul_i32 s3, s3, 10 | ||
; GFX942-NEXT: s_mul_i32 s2, s2, 10 | ||
; GFX942-NEXT: v_mov_b32_e32 v0, s2 | ||
; GFX942-NEXT: v_mov_b32_e32 v1, s3 | ||
; GFX942-NEXT: global_store_dwordx2 v2, v[0:1], s[0:1] | ||
; GFX942-NEXT: s_endpgm | ||
; | ||
; GFX90A-LABEL: global_load_lds_dword_saddr: | ||
; GFX90A: ; %bb.0: ; %main_body | ||
; GFX90A-NEXT: v_mov_b32_e32 v1, v0 | ||
; GFX90A-NEXT: s_mov_b32 s2, s0 | ||
; GFX90A-NEXT: ; kill: def $sgpr2 killed $sgpr2 def $sgpr2_sgpr3 | ||
; GFX90A-NEXT: s_mov_b32 s3, s1 | ||
; GFX90A-NEXT: ; kill: def $sgpr0_sgpr1 killed $sgpr2_sgpr3 | ||
; GFX90A-NEXT: s_getpc_b64 s[0:1] | ||
; GFX90A-NEXT: s_add_u32 s0, s0, G@gotpcrel32@lo+4 | ||
; GFX90A-NEXT: s_addc_u32 s1, s1, G@gotpcrel32@hi+12 | ||
; GFX90A-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x0 | ||
; GFX90A-NEXT: s_waitcnt lgkmcnt(0) | ||
; GFX90A-NEXT: s_load_dwordx2 s[8:9], s[0:1], 0x0 | ||
; GFX90A-NEXT: v_mov_b32_e32 v0, 0 | ||
; GFX90A-NEXT: s_waitcnt lgkmcnt(0) | ||
; GFX90A-NEXT: s_mov_b32 s4, s9 | ||
; GFX90A-NEXT: s_mov_b32 s6, 10 | ||
; GFX90A-NEXT: s_mul_i32 s4, s4, s6 | ||
; GFX90A-NEXT: s_mov_b32 s5, s8 | ||
; GFX90A-NEXT: s_mul_i32 s5, s5, s6 | ||
; GFX90A-NEXT: v_mov_b32_e32 v2, s5 | ||
; GFX90A-NEXT: v_mov_b32_e32 v4, s4 | ||
; GFX90A-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec | ||
; GFX90A-NEXT: v_mov_b32_e32 v3, v4 | ||
; GFX90A-NEXT: ; implicit-def: $sgpr4 | ||
; GFX90A-NEXT: v_readfirstlane_b32 s4, v1 | ||
; GFX90A-NEXT: s_mov_b32 m0, s4 | ||
; GFX90A-NEXT: s_nop 0 | ||
; GFX90A-NEXT: global_load_dword v0, s[2:3] offset:32 slc lds | ||
; GFX90A-NEXT: s_waitcnt lgkmcnt(0) | ||
; GFX90A-NEXT: global_store_dwordx2 v0, v[2:3], s[0:1] | ||
; GFX90A-NEXT: s_endpgm | ||
main_body: | ||
%LGV = load <2 x i32>, ptr addrspace(1) @G, align 8 | ||
%B = mul <2 x i32> %LGV, splat (i32 10) | ||
call void @llvm.amdgcn.global.load.lds(ptr addrspace(1) %gptr, ptr addrspace(3) %lptr, i32 4, i32 32, i32 2) | ||
store <2 x i32> %B, ptr addrspace(1) @G, align 8 | ||
ret void | ||
} |
20 changes: 20 additions & 0 deletions
20
llvm/test/CodeGen/AMDGPU/hazard-flat-instruction-valu-check.mir
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 5 | ||
# RUN: llc -mtriple=amdgcn -mcpu=gfx942 -verify-machineinstrs -run-pass=post-RA-hazard-rec %s -o - | FileCheck -check-prefix=GCN %s | ||
|
||
--- | ||
name: test_flat_valu_hazard | ||
noVRegs: true | ||
body: | | ||
bb.0: | ||
liveins: $vgpr0, $vgpr1 | ||
|
||
; GCN-LABEL: name: test_flat_valu_hazard | ||
; GCN: liveins: $vgpr0, $vgpr1 | ||
; GCN-NEXT: {{ $}} | ||
; GCN-NEXT: GLOBAL_LOAD_LDS_DWORD_SADDR killed $sgpr0_sgpr1, killed $vgpr0, 32, 2, implicit $m0, implicit $exec | ||
; GCN-NEXT: $vgpr0 = V_MOV_B32_e32 killed $vgpr1, implicit $exec, implicit $exec | ||
; GCN-NEXT: FLAT_STORE_DWORDX2 killed renamable $vgpr2_vgpr3, killed renamable $vgpr0_vgpr1, 0, 0, implicit $exec, implicit $flat_scr | ||
GLOBAL_LOAD_LDS_DWORD_SADDR killed $sgpr0_sgpr1, killed $vgpr0, 32, 2, implicit $m0, implicit $exec | ||
$vgpr0 = V_MOV_B32_e32 killed $vgpr1, implicit $exec, implicit $exec | ||
FLAT_STORE_DWORDX2 killed renamable $vgpr2_vgpr3, killed renamable $vgpr0_vgpr1, 0, 0, implicit $exec, implicit $flat_scr | ||
... |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the MIMG case above doing anything? It looks like it's just an assert? I'm also surprised we're querying the operand before the instruction type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, seems that way. The comment suggests the code exists more as a reminder to include the assert than check anything -
All our MIMG definitions use a 256-bit T#, so we can skip checking for them.