[llvm] [AMDGPU] Fix typo in v_dot4 combine (PR #115224)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 6 18:32:36 PST 2024


================
@@ -0,0 +1,116 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
+; RUN: llc -mtriple=amdgcn -mcpu=gfx1100 --start-before=amdgpu-isel -verify-machineinstrs < %s | FileCheck -check-prefixes=GFX11 %s
+
+; The first (A) operand of the v_dot4 is derived from the LHS of the mul chain (that is %l6080, %l7081, %l8082, %l9083). 
+; These correspond to the 5th, 6th, 7th and 8th byte in the load %7. 
+; Confirm that we are actually accessing these bytes. 
+;
+; Previously, we used the dword offset from the corresponding byte in the second (B) operand. 
+; The result was to access the 3rd byte of %7 instead of the 7th (i.e. a dword offset of 0 instead of 1).
+
+define amdgpu_kernel void @ByteOffsetCorrectness(ptr addrspace(1) noalias readonly align 16 %inptr0, ptr addrspace(1) noalias readonly align 16 %inptr1, ptr addrspace(1) noalias align 16 %inptr2, ptr addrspace(1) %outptr) local_unnamed_addr #0 {
+; GFX11-LABEL: ByteOffsetCorrectness:
+; GFX11:       ; %bb.0: ; %.entry
+; GFX11-NEXT:    v_bfe_u32 v2, v0, 20, 10
+; GFX11-NEXT:    s_clause 0x1
+; GFX11-NEXT:    s_load_b128 s[4:7], s[2:3], 0x24
+; GFX11-NEXT:    s_load_b64 s[0:1], s[2:3], 0x3c
+; GFX11-NEXT:    v_bfe_u32 v6, v0, 10, 10
+; GFX11-NEXT:    v_and_b32_e32 v7, 0x3ff, v0
+; GFX11-NEXT:    v_mul_hi_u32_u24_e32 v1, 0x900, v2
+; GFX11-NEXT:    v_mul_u32_u24_e32 v0, 0x900, v2
+; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_2)
+; GFX11-NEXT:    v_add_nc_u32_e32 v8, v6, v2
+; GFX11-NEXT:    v_mad_u64_u32 v[4:5], null, 0x900, v6, v[0:1]
+; GFX11-NEXT:    v_mov_b32_e32 v6, 0
+; GFX11-NEXT:    v_mul_hi_u32_u24_e32 v3, 0x48, v7
+; GFX11-NEXT:    v_mul_u32_u24_e32 v2, 0x48, v7
+; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_2)
+; GFX11-NEXT:    v_mad_u64_u32 v[0:1], null, 0x900, v8, v[2:3]
+; GFX11-NEXT:    v_mad_u64_u32 v[2:3], null, 0x48, v7, v[4:5]
+; GFX11-NEXT:    s_waitcnt lgkmcnt(0)
+; GFX11-NEXT:    v_add_co_u32 v4, vcc_lo, s4, v0
+; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
+; GFX11-NEXT:    v_add_co_ci_u32_e32 v5, vcc_lo, s5, v1, vcc_lo
+; GFX11-NEXT:    v_add_co_u32 v2, vcc_lo, s4, v2
+; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_4)
+; GFX11-NEXT:    v_add_co_ci_u32_e32 v3, vcc_lo, s5, v3, vcc_lo
+; GFX11-NEXT:    v_add_co_u32 v0, vcc_lo, s6, v0
+; GFX11-NEXT:    v_add_co_ci_u32_e32 v1, vcc_lo, s7, v1, vcc_lo
+; GFX11-NEXT:    s_clause 0x2
+; GFX11-NEXT:    global_load_i8 v7, v[4:5], off offset:7
+; GFX11-NEXT:    global_load_i8 v2, v[2:3], off offset:8
+; GFX11-NEXT:    global_load_d16_b16 v6, v[4:5], off offset:5
+; GFX11-NEXT:    s_clause 0x1
+; GFX11-NEXT:    global_load_i8 v3, v[0:1], off offset:8
+; GFX11-NEXT:    global_load_b64 v[0:1], v[0:1], off
+; GFX11-NEXT:    s_waitcnt vmcnt(0)
+; GFX11-NEXT:    v_perm_b32 v0, v2, v7, 0x4000c0c
+; GFX11-NEXT:    v_perm_b32 v2, v6, v6, 0xc0c0100
+; GFX11-NEXT:    v_perm_b32 v1, v3, v1, 0x4030201
+; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_2)
+; GFX11-NEXT:    v_or_b32_e32 v0, v0, v2
+; GFX11-NEXT:    v_mov_b32_e32 v2, 0
+; GFX11-NEXT:    v_dot4_i32_iu8 v0, v1, v0, 0 neg_lo:[1,1,0]
+; GFX11-NEXT:    global_store_b32 v2, v0, s[0:1]
+; GFX11-NEXT:    s_endpgm
+.entry:
+  %ByteOffsetCorrectness.kernarg.segment = call nonnull align 16 dereferenceable(280) ptr addrspace(4) @llvm.amdgcn.kernarg.segment.ptr()
+  %workitemx = tail call i32 @llvm.amdgcn.workitem.id.x()
+  %sworkitemx = sext i32 %workitemx to i64
+  %workitemy = tail call i32 @llvm.amdgcn.workitem.id.y()
+  %sworkitemy = sext i32 %workitemy to i64
+  %workitemz = tail call i32 @llvm.amdgcn.workitem.id.z()
+  %sworkitemz = sext i32 %workitemz to i64
+  %ivtemp0 = add i64 %sworkitemy, %sworkitemz
+  %ivtemp1 = shl nsw i64 %ivtemp0, 5
+  %iv = add nsw i64 %ivtemp1, %sworkitemx
+  %0 = mul nsw i64 %ivtemp0, 2304
----------------
arsenm wrote:

Use named values in tests 

https://github.com/llvm/llvm-project/pull/115224


More information about the llvm-commits mailing list