Skip to content

Commit 6e3465c

Browse files
authored
[AArch64] Fix ldp rename through a bundle (#146415)
std::prev(Paired) will get the previous instruction, that might skip over the instructions in a bundle to the BUNDLE itself. Change it to Paired->getPrevNode() to make sure we update the registers in each instruction in the bundle.
1 parent 5332534 commit 6e3465c

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,8 +1081,8 @@ AArch64LoadStoreOpt::mergePairedInsns(MachineBasicBlock::iterator I,
10811081
LLVM_DEBUG(dbgs() << "Renamed " << MI);
10821082
return true;
10831083
};
1084-
forAllMIsUntilDef(MergeForward ? *I : *std::prev(Paired), RegToRename, TRI,
1085-
UINT32_MAX, UpdateMIs);
1084+
forAllMIsUntilDef(MergeForward ? *I : *Paired->getPrevNode(), RegToRename,
1085+
TRI, UINT32_MAX, UpdateMIs);
10861086

10871087
#if !defined(NDEBUG)
10881088
// For forward merging store:

llvm/test/CodeGen/AArch64/stp-opt-with-renaming.mir

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,35 @@ body: |
735735
RET undef $lr
736736
...
737737
---
738+
name: bundled_load_rename
739+
alignment: 4
740+
tracksRegLiveness: true
741+
frameInfo:
742+
maxAlignment: 1
743+
maxCallFrameSize: 0
744+
machineFunctionInfo:
745+
hasRedZone: false
746+
body: |
747+
bb.0.entry:
748+
liveins: $z3, $z19, $p0, $z16
749+
; CHECK-LABEL: name: bundled_load_rename
750+
; CHECK: liveins: $z3, $z19, $p0, $z16
751+
; CHECK-NEXT: {{ $}}
752+
; CHECK-NEXT: renamable $q16, $q20 = LDPQi $sp, 0 :: (load (s128)), (load (s128), align 32)
753+
; CHECK-NEXT: BUNDLE implicit-def $z3, implicit-def $q3, implicit-def $d3, implicit-def $s3, implicit-def $h3, implicit-def $b3, implicit $z19, implicit $p0, implicit $z20 {
754+
; CHECK-NEXT: $z3 = MOVPRFX_ZZ $z19
755+
; CHECK-NEXT: $z3 = FMUL_ZPmZ_S renamable $p0, killed $z3, $z20
756+
; CHECK-NEXT: }
757+
; CHECK-NEXT: RET undef $lr
758+
renamable $q16 = LDRQui $sp, 1 :: (load 16)
759+
BUNDLE implicit-def $z3, implicit-def $q3, implicit-def $d3, implicit-def $s3, implicit-def $h3, implicit-def $b3, implicit $z19, implicit $p0, implicit $z16 {
760+
$z3 = MOVPRFX_ZZ $z19
761+
$z3 = FMUL_ZPmZ_S renamable $p0, killed $z3, renamable $z16
762+
}
763+
renamable $q16 = LDRQui $sp, 0 :: (load 16, align 32)
764+
RET undef $lr
765+
...
766+
---
738767
#
739768
# CHECK-LABEL: name: bundled_use
740769
# CHECK: renamable $q0 = LDRQui $sp, 1

0 commit comments

Comments
 (0)