Skip to content

Commit 4a67118

Browse files
committed
[AArch64PostCoalescer] Propagate undef flag after replacing
When replacing the register, if the source register has undef flag, we should propagate the flag to all uses of the destination register.
1 parent e11f8a4 commit 4a67118

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

llvm/lib/Target/AArch64/AArch64PostCoalescerPass.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ bool AArch64PostCoalescer::runOnMachineFunction(MachineFunction &MF) {
7575
if (Src != Dst)
7676
MRI->replaceRegWith(Dst, Src);
7777

78+
if (MI.getOperand(1).isUndef())
79+
for (MachineOperand &MO : MRI->use_operands(Dst))
80+
MO.setIsUndef();
81+
7882
// MI must be erased from the basic block before recalculating the live
7983
// interval.
8084
LIS->RemoveMachineInstrFromMaps(MI);
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# RUN: llc -mtriple=aarch64 -mattr=+sme -run-pass=aarch64-post-coalescer-pass -o - %s | FileCheck %s
2+
3+
---
4+
name: foo
5+
body: |
6+
bb.0.entry:
7+
RET_ReallyLR
8+
...
9+
---
10+
name: bar
11+
machineFunctionInfo:
12+
hasStreamingModeChanges: true
13+
body: |
14+
bb.0.entry:
15+
; CHECK-LABEL: name: bar
16+
; CHECK: ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp
17+
; CHECK-NEXT: MSRpstatesvcrImm1 1, 1, csr_aarch64_smstartstop, implicit-def dead $nzcv, implicit-def $sp, implicit-def dead $d0, implicit $vg, implicit-def $vg, implicit-def $fpmr
18+
; CHECK-NEXT: $d0 = COPY undef %0:fpr64
19+
; CHECK-NEXT: BL @foo, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit killed $d0, implicit-def $sp
20+
; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp
21+
; CHECK-NEXT: MSRpstatesvcrImm1 1, 0, csr_aarch64_smstartstop, implicit-def dead $nzcv, implicit $vg, implicit-def $vg, implicit-def $fpmr
22+
; CHECK-NEXT: RET_ReallyLR
23+
ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp
24+
%1:fpr64 = COALESCER_BARRIER_FPR64 undef %1
25+
MSRpstatesvcrImm1 1, 1, csr_aarch64_smstartstop, implicit-def dead $nzcv, implicit-def $sp, implicit-def dead $d0, implicit $vg, implicit-def $vg, implicit-def $fpmr
26+
$d0 = COPY %1
27+
BL @foo, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit killed $d0, implicit-def $sp
28+
ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp
29+
MSRpstatesvcrImm1 1, 0, csr_aarch64_smstartstop, implicit-def dead $nzcv, implicit $vg, implicit-def $vg, implicit-def $fpmr
30+
RET_ReallyLR
31+
...

0 commit comments

Comments
 (0)