Skip to content

Commit 0ef2512

Browse files
committed
Address review and update tests
1 parent b5e2d06 commit 0ef2512

File tree

3 files changed

+17
-22
lines changed

3 files changed

+17
-22
lines changed

llvm/lib/Target/AMDGPU/SIPeepholeSDWA.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -345,20 +345,19 @@ MachineInstr *SDWASrcOperand::potentialToConvert(const SIInstrInfo *TII,
345345
return nullptr;
346346
}
347347

348-
349348
for (MachineInstr &UseMI : getMRI()->use_nodbg_instructions(Reg->getReg())) {
350-
// If there exist use of subreg of Reg then return nullptr
351-
if (!isSameReg(UseMO, *Reg))
352-
return nullptr;
353-
354-
// Check that all instructions the use Reg can be converted
349+
// Check that all instructions that use Reg can be converted
355350
if (!isConvertibleToSDWA(UseMI, ST, TII)) {
356351
return nullptr;
357352
}
358353
}
354+
359355
// Now that it's guaranteed all uses are legal, iterate over the uses again
360356
// to add them for later conversion.
361357
for (MachineOperand &UseMO : getMRI()->use_nodbg_operands(Reg->getReg())) {
358+
// Should not get a subregister here
359+
assert(isSameReg(UseMO, *Reg));
360+
362361
SDWAOperandsMap& potentialMatchesMap = *PotentialMatches;
363362
MachineInstr* UseMI = UseMO.getParent();
364363
potentialMatchesMap[UseMI].push_back(this);

llvm/test/CodeGen/AMDGPU/llvm.fmuladd.f16.ll

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -659,31 +659,28 @@ define amdgpu_kernel void @fmuladd_v2f16(
659659
; VI-FLUSH-NEXT: s_mov_b32 s14, s10
660660
; VI-FLUSH-NEXT: s_mov_b32 s15, s11
661661
; VI-FLUSH-NEXT: s_waitcnt lgkmcnt(0)
662+
; VI-FLUSH-NEXT: s_mov_b32 s12, s2
663+
; VI-FLUSH-NEXT: s_mov_b32 s13, s3
662664
; VI-FLUSH-NEXT: s_mov_b32 s16, s4
663665
; VI-FLUSH-NEXT: s_mov_b32 s17, s5
666+
; VI-FLUSH-NEXT: s_mov_b32 s18, s10
667+
; VI-FLUSH-NEXT: s_mov_b32 s19, s11
664668
; VI-FLUSH-NEXT: s_mov_b32 s4, s6
665669
; VI-FLUSH-NEXT: s_mov_b32 s5, s7
666670
; VI-FLUSH-NEXT: s_mov_b32 s6, s10
667671
; VI-FLUSH-NEXT: s_mov_b32 s7, s11
668-
; VI-FLUSH-NEXT: s_mov_b32 s12, s2
669-
; VI-FLUSH-NEXT: s_mov_b32 s13, s3
670-
; VI-FLUSH-NEXT: s_mov_b32 s18, s10
671-
; VI-FLUSH-NEXT: s_mov_b32 s19, s11
672-
; VI-FLUSH-NEXT: buffer_load_dword v0, off, s[4:7], 0
673-
; VI-FLUSH-NEXT: buffer_load_dword v1, off, s[16:19], 0
674-
; VI-FLUSH-NEXT: buffer_load_dword v2, off, s[12:15], 0
672+
; VI-FLUSH-NEXT: buffer_load_dword v0, off, s[12:15], 0
673+
; VI-FLUSH-NEXT: buffer_load_dword v1, off, s[4:7], 0
674+
; VI-FLUSH-NEXT: buffer_load_dword v2, off, s[16:19], 0
675675
; VI-FLUSH-NEXT: s_mov_b32 s8, s0
676676
; VI-FLUSH-NEXT: s_mov_b32 s9, s1
677-
; VI-FLUSH-NEXT: s_waitcnt vmcnt(2)
678-
; VI-FLUSH-NEXT: v_lshrrev_b32_e32 v3, 16, v0
679677
; VI-FLUSH-NEXT: s_waitcnt vmcnt(1)
680-
; VI-FLUSH-NEXT: v_lshrrev_b32_e32 v4, 16, v1
678+
; VI-FLUSH-NEXT: v_lshrrev_b32_e32 v3, 16, v1
681679
; VI-FLUSH-NEXT: s_waitcnt vmcnt(0)
682-
; VI-FLUSH-NEXT: v_lshrrev_b32_e32 v5, 16, v2
683-
; VI-FLUSH-NEXT: v_mac_f16_e32 v3, v5, v4
680+
; VI-FLUSH-NEXT: v_mac_f16_sdwa v3, v0, v2 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_1 src1_sel:WORD_1
684681
; VI-FLUSH-NEXT: v_lshlrev_b32_e32 v3, 16, v3
685-
; VI-FLUSH-NEXT: v_mac_f16_e32 v0, v2, v1
686-
; VI-FLUSH-NEXT: v_or_b32_e32 v0, v0, v3
682+
; VI-FLUSH-NEXT: v_mac_f16_e32 v1, v0, v2
683+
; VI-FLUSH-NEXT: v_or_b32_e32 v0, v1, v3
687684
; VI-FLUSH-NEXT: buffer_store_dword v0, off, s[8:11], 0
688685
; VI-FLUSH-NEXT: s_endpgm
689686
;

llvm/test/CodeGen/AMDGPU/sdwa-peephole.ll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1557,8 +1557,7 @@ define amdgpu_kernel void @mac_v2half(ptr addrspace(1) %out, ptr addrspace(1) %i
15571557
; GFX89-NEXT: s_waitcnt vmcnt(1)
15581558
; GFX89-NEXT: v_lshrrev_b32_e32 v4, 16, v2
15591559
; GFX89-NEXT: s_waitcnt vmcnt(0)
1560-
; GFX89-NEXT: v_lshrrev_b32_e32 v5, 16, v3
1561-
; GFX89-NEXT: v_mac_f16_sdwa v4, v5, v2 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:WORD_1
1560+
; GFX89-NEXT: v_mac_f16_sdwa v4, v3, v2 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_1 src1_sel:WORD_1
15621561
; GFX89-NEXT: v_lshlrev_b32_e32 v4, 16, v4
15631562
; GFX89-NEXT: v_mac_f16_e32 v2, v3, v2
15641563
; GFX89-NEXT: v_or_b32_e32 v2, v2, v4

0 commit comments

Comments
 (0)