-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[AMDGPU][True16][CodeGen] readfirstlane for vgpr16 copy to sgpr32 #118037
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
broxigarchen
merged 3 commits into
llvm:main
from
broxigarchen:main-merge-true16-fix-sgpr
May 5, 2025
Merged
Changes from 1 commit
Commits
Show all changes
3 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
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
41 changes: 41 additions & 0 deletions
41
llvm/test/CodeGen/AMDGPU/fix-sgpr-copies-vgpr16-to-spgr32.ll
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,41 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 3 | ||
; RUN: llc -mtriple=amdgcn -mcpu=gfx1100 -mattr=+real-true16 < %s | FileCheck %s | ||
|
||
; expect readfirstlane to pick the 32bit register | ||
define amdgpu_gs i32 @vgpr16_copyto_sgpr(ptr addrspace(3) %a, i32 %b, ptr addrspace(1) %out) { | ||
; CHECK-LABEL: vgpr16_copyto_sgpr: | ||
; CHECK: ; %bb.0: ; %entry | ||
; CHECK-NEXT: ds_load_2addr_b32 v[0:1], v0 offset1:1 | ||
; CHECK-NEXT: s_waitcnt lgkmcnt(0) | ||
; CHECK-NEXT: v_cvt_f16_f32_e32 v0.l, v0 | ||
; CHECK-NEXT: s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1) | ||
; CHECK-NEXT: v_readfirstlane_b32 s0, v0 | ||
; CHECK-NEXT: s_and_b32 s0, 0xffff, s0 | ||
; CHECK-NEXT: s_mul_i32 s0, s0, 5 | ||
; CHECK-NEXT: s_delay_alu instid0(SALU_CYCLE_1) | ||
; CHECK-NEXT: s_cmp_lg_u32 s0, 2 | ||
; CHECK-NEXT: s_cbranch_scc1 .LBB0_2 | ||
; CHECK-NEXT: ; %bb.1: ; %a1 | ||
; CHECK-NEXT: s_mov_b32 s0, 1 | ||
; CHECK-NEXT: s_branch .LBB0_3 | ||
; CHECK-NEXT: .LBB0_2: ; %a2 | ||
; CHECK-NEXT: s_mov_b32 s0, 2 | ||
; CHECK-NEXT: s_branch .LBB0_3 | ||
; CHECK-NEXT: .LBB0_3: | ||
entry: | ||
%1 = load <4 x float>, ptr addrspace(3) poison, align 4 | ||
%2 = extractelement <4 x float> %1, i32 0 | ||
%3 = fptrunc float %2 to half | ||
%4 = bitcast half %3 to i16 | ||
%5 = zext i16 %4 to i32 | ||
%6 = add i32 %5, 1 | ||
%7 = mul i32 %6, 5 | ||
%8 = icmp eq i32 %7, 7 | ||
arsenm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
br i1 %8, label %a1, label %a2 | ||
|
||
a1: | ||
ret i32 1 | ||
|
||
a2: | ||
ret i32 2 | ||
} |
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.
Are you reaching here in practice?
Uh oh!
There was an error while loading. Please reload this page.
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.
Hi Matt. I think we probably never hit this before in the previous code. But with the true16 flow, we should hit here.
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.
Not exactly, we don't want SIFixSGPRCopies to need to handle anything
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.
Hi Matt. Can you help to elaborate a bit here? Do you think we should not see this 16bit handling in this pass? Thanks!
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.
It does need to be handled here, but if you're seeing this in practice something else is likely missing
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.
This code fixed the conformance test I was looking at, and as you say it should be handled here, so I think it should be merged.
Regarding an 'alternative fix', do you have any hypothesis what that would be? Is it a priority to find that?
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.
It depends what it is. Either way that indicates we should have an end to end IR test for whatever this issue was as well
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.
Updated this PR's decsription to answer this question