-
Notifications
You must be signed in to change notification settings - Fork 13.7k
[AMDGPU][True16][CodeGen] support v_mov_b16 and v_swap_b16 in true16 format #102198
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
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
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,110 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py | ||
; RUN: llc -march=amdgcn -mcpu=gfx1100 -mattr=+real-true16 -verify-machineinstrs < %s | FileCheck -check-prefixes=GFX11-TRUE16 %s | ||
; RUN: llc -march=amdgcn -mcpu=gfx1100 -mattr=-real-true16 -verify-machineinstrs < %s | FileCheck -check-prefixes=GFX11-FAKE16 %s | ||
; RUN: llc -march=amdgcn -mcpu=gfx1200 -mattr=+real-true16 -verify-machineinstrs < %s | FileCheck -check-prefixes=GFX12-TRUE16 %s | ||
; RUN: llc -march=amdgcn -mcpu=gfx1200 -mattr=-real-true16 -verify-machineinstrs < %s | FileCheck -check-prefixes=GFX12-FAKE16 %s | ||
|
||
define half @swap(half %a, half %b, i32 %i) { | ||
; GFX11-TRUE16-LABEL: swap: | ||
; GFX11-TRUE16: ; %bb.0: ; %entry | ||
; GFX11-TRUE16-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
; GFX11-TRUE16-NEXT: v_mov_b16_e32 v0.h, v0.l | ||
; GFX11-TRUE16-NEXT: v_mov_b16_e32 v0.l, v1.l | ||
; GFX11-TRUE16-NEXT: s_mov_b32 s0, 0 | ||
; GFX11-TRUE16-NEXT: .LBB0_1: ; %loop | ||
; GFX11-TRUE16-NEXT: ; =>This Inner Loop Header: Depth=1 | ||
; GFX11-TRUE16-NEXT: v_add_nc_u32_e32 v2, -1, v2 | ||
; GFX11-TRUE16-NEXT: s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_3) | ||
; GFX11-TRUE16-NEXT: v_mov_b16_e32 v1.l, v0.l | ||
; GFX11-TRUE16-NEXT: v_swap_b16 v0.l, v0.h | ||
; GFX11-TRUE16-NEXT: v_cmp_eq_u32_e32 vcc_lo, 0, v2 | ||
; GFX11-TRUE16-NEXT: s_or_b32 s0, vcc_lo, s0 | ||
; GFX11-TRUE16-NEXT: s_delay_alu instid0(SALU_CYCLE_1) | ||
; GFX11-TRUE16-NEXT: s_and_not1_b32 exec_lo, exec_lo, s0 | ||
; GFX11-TRUE16-NEXT: s_cbranch_execnz .LBB0_1 | ||
; GFX11-TRUE16-NEXT: ; %bb.2: ; %ret | ||
; GFX11-TRUE16-NEXT: s_or_b32 exec_lo, exec_lo, s0 | ||
; GFX11-TRUE16-NEXT: s_setpc_b64 s[30:31] | ||
; | ||
; GFX11-FAKE16-LABEL: swap: | ||
; GFX11-FAKE16: ; %bb.0: ; %entry | ||
; GFX11-FAKE16-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
; GFX11-FAKE16-NEXT: s_mov_b32 s0, 0 | ||
; GFX11-FAKE16-NEXT: .LBB0_1: ; %loop | ||
; GFX11-FAKE16-NEXT: ; =>This Inner Loop Header: Depth=1 | ||
; GFX11-FAKE16-NEXT: s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_2) | ||
; GFX11-FAKE16-NEXT: v_dual_mov_b32 v3, v1 :: v_dual_add_nc_u32 v2, -1, v2 | ||
; GFX11-FAKE16-NEXT: v_swap_b32 v1, v0 | ||
; GFX11-FAKE16-NEXT: v_cmp_eq_u32_e32 vcc_lo, 0, v2 | ||
; GFX11-FAKE16-NEXT: s_or_b32 s0, vcc_lo, s0 | ||
; GFX11-FAKE16-NEXT: s_delay_alu instid0(SALU_CYCLE_1) | ||
; GFX11-FAKE16-NEXT: s_and_not1_b32 exec_lo, exec_lo, s0 | ||
; GFX11-FAKE16-NEXT: s_cbranch_execnz .LBB0_1 | ||
; GFX11-FAKE16-NEXT: ; %bb.2: ; %ret | ||
; GFX11-FAKE16-NEXT: s_or_b32 exec_lo, exec_lo, s0 | ||
; GFX11-FAKE16-NEXT: v_mov_b32_e32 v0, v1 | ||
; GFX11-FAKE16-NEXT: s_setpc_b64 s[30:31] | ||
; | ||
; GFX12-TRUE16-LABEL: swap: | ||
; GFX12-TRUE16: ; %bb.0: ; %entry | ||
; GFX12-TRUE16-NEXT: s_wait_loadcnt_dscnt 0x0 | ||
; GFX12-TRUE16-NEXT: s_wait_expcnt 0x0 | ||
; GFX12-TRUE16-NEXT: s_wait_samplecnt 0x0 | ||
; GFX12-TRUE16-NEXT: s_wait_bvhcnt 0x0 | ||
; GFX12-TRUE16-NEXT: s_wait_kmcnt 0x0 | ||
; GFX12-TRUE16-NEXT: v_mov_b16_e32 v0.h, v0.l | ||
; GFX12-TRUE16-NEXT: v_mov_b16_e32 v0.l, v1.l | ||
; GFX12-TRUE16-NEXT: s_mov_b32 s0, 0 | ||
; GFX12-TRUE16-NEXT: .LBB0_1: ; %loop | ||
; GFX12-TRUE16-NEXT: ; =>This Inner Loop Header: Depth=1 | ||
; GFX12-TRUE16-NEXT: v_add_nc_u32_e32 v2, -1, v2 | ||
; GFX12-TRUE16-NEXT: s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_3) | ||
; GFX12-TRUE16-NEXT: v_mov_b16_e32 v1.l, v0.l | ||
; GFX12-TRUE16-NEXT: v_swap_b16 v0.l, v0.h | ||
; GFX12-TRUE16-NEXT: v_cmp_eq_u32_e32 vcc_lo, 0, v2 | ||
; GFX12-TRUE16-NEXT: s_or_b32 s0, vcc_lo, s0 | ||
; GFX12-TRUE16-NEXT: s_delay_alu instid0(SALU_CYCLE_1) | ||
; GFX12-TRUE16-NEXT: s_and_not1_b32 exec_lo, exec_lo, s0 | ||
; GFX12-TRUE16-NEXT: s_cbranch_execnz .LBB0_1 | ||
; GFX12-TRUE16-NEXT: ; %bb.2: ; %ret | ||
; GFX12-TRUE16-NEXT: s_or_b32 exec_lo, exec_lo, s0 | ||
; GFX12-TRUE16-NEXT: s_setpc_b64 s[30:31] | ||
; | ||
; GFX12-FAKE16-LABEL: swap: | ||
; GFX12-FAKE16: ; %bb.0: ; %entry | ||
; GFX12-FAKE16-NEXT: s_wait_loadcnt_dscnt 0x0 | ||
; GFX12-FAKE16-NEXT: s_wait_expcnt 0x0 | ||
; GFX12-FAKE16-NEXT: s_wait_samplecnt 0x0 | ||
; GFX12-FAKE16-NEXT: s_wait_bvhcnt 0x0 | ||
; GFX12-FAKE16-NEXT: s_wait_kmcnt 0x0 | ||
; GFX12-FAKE16-NEXT: s_mov_b32 s0, 0 | ||
; GFX12-FAKE16-NEXT: .LBB0_1: ; %loop | ||
; GFX12-FAKE16-NEXT: ; =>This Inner Loop Header: Depth=1 | ||
; GFX12-FAKE16-NEXT: s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_2) | ||
; GFX12-FAKE16-NEXT: v_dual_mov_b32 v3, v1 :: v_dual_add_nc_u32 v2, -1, v2 | ||
; GFX12-FAKE16-NEXT: v_swap_b32 v1, v0 | ||
; GFX12-FAKE16-NEXT: v_cmp_eq_u32_e32 vcc_lo, 0, v2 | ||
; GFX12-FAKE16-NEXT: s_or_b32 s0, vcc_lo, s0 | ||
; GFX12-FAKE16-NEXT: s_delay_alu instid0(SALU_CYCLE_1) | ||
; GFX12-FAKE16-NEXT: s_and_not1_b32 exec_lo, exec_lo, s0 | ||
; GFX12-FAKE16-NEXT: s_cbranch_execnz .LBB0_1 | ||
; GFX12-FAKE16-NEXT: ; %bb.2: ; %ret | ||
; GFX12-FAKE16-NEXT: s_or_b32 exec_lo, exec_lo, s0 | ||
; GFX12-FAKE16-NEXT: v_mov_b32_e32 v0, v1 | ||
; GFX12-FAKE16-NEXT: s_setpc_b64 s[30:31] | ||
entry: | ||
br label %loop | ||
|
||
loop: | ||
%x = phi half [%a, %entry], [%y, %loop] | ||
%y = phi half [%b, %entry], [%x, %loop] | ||
%i2 = phi i32 [%i, %entry], [%i3, %loop] | ||
|
||
%i3 = sub i32 %i2, 1 | ||
|
||
%cmp = icmp eq i32 %i3, 0 | ||
br i1 %cmp, label %ret, label %loop | ||
|
||
ret: | ||
ret half %x | ||
} |
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,10 @@ | ||
// RUN: not llvm-mc -triple=amdgcn -mcpu=gfx1100 -mattr=+real-true16 %s 2>&1 | FileCheck --check-prefix=GFX11 --implicit-check-not=error: %s | ||
|
||
v_mov_b16 v0.l, s0.h | ||
// GFX11: :[[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction | ||
|
||
v_mov_b16 v0.l, ttmp0.h | ||
// GFX11: :[[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction | ||
|
||
v_mov_b16 v0.l, a0.h | ||
// GFX11: :[[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction |
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.
I don't expect to need special casing here. Should this be filtered in isFoldableCopy? I thought we had filtering for regular v_mov_b32_e64 already somewhere here
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. v_mov_b32_e64 only has 1 source operand so we don't need the filtering.
V_MOV_B16_t16_e64 has three input operands and I think it is only instruction in the FoldableCopy list that has more than 1 operand:
inoperandlist: src_modifiers, src0, op_sel
so it need some special handling here.
I think we could move the filtering to isFoldableCopy though, but we need still need the special handling to select the correct operand. What do you think?