-
Notifications
You must be signed in to change notification settings - Fork 14.3k
AMDGPU: Fix gfx950 ashr pk i8/u8 patterns #130040
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
arsenm
merged 1 commit into
main
from
users/arsenm/gfx950/fix-ashr-pk-i8-u8-pattern-merge-issue
Mar 7, 2025
Merged
AMDGPU: Fix gfx950 ashr pk i8/u8 patterns #130040
arsenm
merged 1 commit into
main
from
users/arsenm/gfx950/fix-ashr-pk-i8-u8-pattern-merge-issue
Mar 7, 2025
Conversation
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
The correct version of the pattern got lost in a merge somewhere
@llvm/pr-subscribers-backend-amdgpu Author: Matt Arsenault (arsenm) ChangesThe correct version of the pattern got lost in a merge somewhere Full diff: https://github.com/llvm/llvm-project/pull/130040.diff 2 Files Affected:
diff --git a/llvm/lib/Target/AMDGPU/VOP3Instructions.td b/llvm/lib/Target/AMDGPU/VOP3Instructions.td
index b80ad366b2796..a03a6f61ce0cb 100644
--- a/llvm/lib/Target/AMDGPU/VOP3Instructions.td
+++ b/llvm/lib/Target/AMDGPU/VOP3Instructions.td
@@ -1547,14 +1547,14 @@ let SubtargetPredicate = HasAshrPkInsts, isReMaterializable = 1 in {
} // End SubtargetPredicate = HasAshrPkInsts, isReMaterializable = 1
class AshrPkI8Pat<VOP3_Pseudo inst, int lo, int hi>: GCNPat<
- (i16 (or (i16 (shl (i16 (trunc (i32 (AMDGPUsmed3 (i32 (sra i32:$src1, i32:$src2)), (i32 lo), (i32 hi))))), (i16 8))),
- (i16 (and (i16 (trunc (i32 (AMDGPUsmed3 (i32 (sra i32:$src0, i32:$src2)), (i32 lo), (i32 hi))))), (i16 255))))),
+ (i32 (or (i32 (shl (i32 (AMDGPUsmed3 (i32 (sra i32:$src1, i32:$src2)), (i32 lo), (i32 hi))), (i32 8))),
+ (i32 (and (i32 (AMDGPUsmed3 (i32 (sra i32:$src0, i32:$src2)), (i32 lo), (i32 hi))), (i32 255))))),
(inst 0, VSrc_b32:$src0, 0, VSrc_b32:$src1, 0, VSrc_b32:$src2, 0 )
>;
class AshrPkU8Pat<VOP3_Pseudo inst, int lo, int hi>: GCNPat<
- (i16 (or (i16 (shl (i16 (trunc (i32 (AMDGPUsmed3 (i32 (sra i32:$src1, i32:$src2)), (i32 lo), (i32 hi))))), (i16 8))),
- (i16 (trunc (i32 (AMDGPUsmed3 (i32 (sra i32:$src0, i32:$src2)), (i32 lo), (i32 hi))))))),
+ (i32 (or (i32 (shl (i32 (AMDGPUsmed3 (i32 (sra i32:$src1, i32:$src2)), (i32 lo), (i32 hi))), (i32 8))),
+ (i32 (AMDGPUsmed3 (i32 (sra i32:$src0, i32:$src2)), (i32 lo), (i32 hi))))),
(inst 0, VSrc_b32:$src0, 0, VSrc_b32:$src1, 0, VSrc_b32:$src2, 0 )
>;
diff --git a/llvm/test/CodeGen/AMDGPU/v_ashr_pk.ll b/llvm/test/CodeGen/AMDGPU/v_ashr_pk.ll
index b5f43f9f68936..684ab8046563d 100644
--- a/llvm/test/CodeGen/AMDGPU/v_ashr_pk.ll
+++ b/llvm/test/CodeGen/AMDGPU/v_ashr_pk.ll
@@ -5,16 +5,12 @@ define amdgpu_kernel void @v_ashr_pk_i8_i32(ptr addrspace(1) %out, i32 %src0, i3
; GFX950: ; %bb.0:
; GFX950-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x2c
; GFX950-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x24
-; GFX950-NEXT: v_mov_b32_e32 v1, 0xffffff80
-; GFX950-NEXT: v_mov_b32_e32 v2, 0x7f
; GFX950-NEXT: v_mov_b32_e32 v0, 0
; GFX950-NEXT: s_waitcnt lgkmcnt(0)
-; GFX950-NEXT: s_ashr_i32 s1, s1, s2
-; GFX950-NEXT: s_ashr_i32 s0, s0, s2
-; GFX950-NEXT: v_med3_i32 v3, s0, v1, v2
-; GFX950-NEXT: v_med3_i32 v1, s1, v1, v2
-; GFX950-NEXT: v_lshlrev_b32_e32 v1, 8, v1
-; GFX950-NEXT: v_or_b32_sdwa v1, v3, v1 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:BYTE_0 src1_sel:DWORD
+; GFX950-NEXT: s_and_b32 s2, s2, 31
+; GFX950-NEXT: v_mov_b32_e32 v1, s1
+; GFX950-NEXT: v_mov_b32_e32 v2, s2
+; GFX950-NEXT: v_ashr_pk_i8_i32 v1, s0, v1, v2
; GFX950-NEXT: global_store_short v0, v1, s[6:7]
; GFX950-NEXT: s_endpgm
%insert.0 = insertelement <2 x i32> poison, i32 %src0, i64 0
@@ -36,15 +32,12 @@ define amdgpu_kernel void @v_ashr_pk_u8_i32(ptr addrspace(1) %out, i32 %src0, i3
; GFX950: ; %bb.0:
; GFX950-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x2c
; GFX950-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x24
-; GFX950-NEXT: v_mov_b32_e32 v1, 0xff
; GFX950-NEXT: v_mov_b32_e32 v0, 0
; GFX950-NEXT: s_waitcnt lgkmcnt(0)
-; GFX950-NEXT: s_ashr_i32 s1, s1, s2
-; GFX950-NEXT: s_ashr_i32 s0, s0, s2
-; GFX950-NEXT: v_med3_i32 v2, s0, 0, v1
-; GFX950-NEXT: v_med3_i32 v1, s1, 0, v1
-; GFX950-NEXT: v_lshlrev_b32_e32 v1, 8, v1
-; GFX950-NEXT: v_or_b32_e32 v1, v2, v1
+; GFX950-NEXT: s_and_b32 s2, s2, 31
+; GFX950-NEXT: v_mov_b32_e32 v1, s1
+; GFX950-NEXT: v_mov_b32_e32 v2, s2
+; GFX950-NEXT: v_ashr_pk_u8_i32 v1, s0, v1, v2
; GFX950-NEXT: global_store_short v0, v1, s[6:7]
; GFX950-NEXT: s_endpgm
%insert.0 = insertelement <2 x i32> poison, i32 %src0, i64 0
|
rampitec
approved these changes
Mar 6, 2025
jph-13
pushed a commit
to jph-13/llvm-project
that referenced
this pull request
Mar 21, 2025
The correct version of the pattern got lost in a merge somewhere
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The correct version of the pattern got lost in a merge somewhere