Skip to content

Commit ea9d639

Browse files
committed
Fix reordering of instructions during VirtRegRewriter unbundling
When unbundling COPY bundles in VirtRegRewriter the start of the bundle is not correctly referenced in the unbundling loop. The effect of this is that unbundled instructions are sometimes inserted out-of-order, particular in cases where multiple reordering have been applied to avoid clobbering dependencies. The resulting instruction sequence clobbers dependencies. Reviewed By: foad Differential Revision: https://reviews.llvm.org/D88821
1 parent a48d480 commit ea9d639

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

llvm/lib/CodeGen/VirtRegMap.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ void VirtRegRewriter::expandCopyBundle(MachineInstr &MI) const {
452452
// instruction, the bundle will have been completely undone.
453453
if (BundledMI != BundleStart) {
454454
BundledMI->removeFromBundle();
455-
MBB.insert(FirstMI, BundledMI);
455+
MBB.insert(BundleStart, BundledMI);
456456
} else if (BundledMI->isBundledWithSucc()) {
457457
BundledMI->unbundleFromSucc();
458458
BundleStart = &*std::next(BundledMI->getIterator());

llvm/test/CodeGen/AMDGPU/splitkit-copy-bundle.mir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,11 +298,11 @@ body: |
298298
; VR: SI_SPILL_S512_SAVE killed renamable $sgpr12_sgpr13_sgpr14_sgpr15_sgpr16_sgpr17_sgpr18_sgpr19_sgpr20_sgpr21_sgpr22_sgpr23_sgpr24_sgpr25_sgpr26_sgpr27, %stack.0, implicit $exec, implicit $sgpr0_sgpr1_sgpr2_sgpr3, implicit $sgpr32 :: (store 64 into %stack.0, align 4, addrspace 5)
299299
; VR: S_NOP 0, implicit-def $sgpr8, implicit-def $sgpr12, implicit-def $sgpr16, implicit-def $sgpr20, implicit-def $sgpr24, implicit-def $sgpr28, implicit-def $sgpr32, implicit-def $sgpr36, implicit-def $sgpr40, implicit-def $sgpr44, implicit-def $sgpr48, implicit-def $sgpr52, implicit-def $sgpr56, implicit-def $sgpr60, implicit-def $sgpr64, implicit-def $sgpr68, implicit-def $sgpr72, implicit-def $sgpr74, implicit-def $sgpr78, implicit-def $sgpr82, implicit-def $sgpr86, implicit-def $sgpr90, implicit-def $sgpr94, implicit-def $sgpr98
300300
; VR: renamable $sgpr12_sgpr13_sgpr14_sgpr15_sgpr16_sgpr17_sgpr18_sgpr19_sgpr20_sgpr21_sgpr22_sgpr23_sgpr24_sgpr25_sgpr26_sgpr27 = SI_SPILL_S512_RESTORE %stack.0, implicit $exec, implicit $sgpr0_sgpr1_sgpr2_sgpr3, implicit $sgpr32 :: (load 64 from %stack.0, align 4, addrspace 5)
301-
; VR: renamable $sgpr16 = COPY killed renamable $sgpr20
301+
; VR: renamable $sgpr12_sgpr13 = COPY killed renamable $sgpr16_sgpr17
302302
; VR: renamable $sgpr15 = COPY killed renamable $sgpr19
303303
; VR: renamable $sgpr18_sgpr19 = COPY killed renamable $sgpr22_sgpr23
304+
; VR: renamable $sgpr16 = COPY killed renamable $sgpr20
304305
; VR: renamable $sgpr21 = COPY killed renamable $sgpr25
305-
; VR: renamable $sgpr12_sgpr13 = COPY renamable $sgpr16_sgpr17
306306
; VR: renamable $sgpr22 = COPY killed renamable $sgpr26
307307
; VR: renamable $sgpr4_sgpr5_sgpr6_sgpr7 = IMPLICIT_DEF
308308
; VR: renamable $sgpr8 = S_BUFFER_LOAD_DWORD_SGPR renamable $sgpr4_sgpr5_sgpr6_sgpr7, killed renamable $sgpr12, 0, 0 :: (dereferenceable invariant load 4)

0 commit comments

Comments
 (0)