Skip to content

Commit 2a63b96

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 885d416 commit 2a63b96

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-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: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 6
2+
; RUN: llc -mtriple=aarch64 -mattr=+sme -stop-after=aarch64-post-coalescer-pass < %s | FileCheck %s
3+
4+
target triple = "aarch64"
5+
6+
declare void @foo(double) "aarch64_pstate_sm_enabled"
7+
8+
define dso_local void @bar(double %a) local_unnamed_addr {
9+
; CHECK-LABEL: name: bar
10+
; CHECK: bb.0.entry:
11+
; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp
12+
; 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
13+
; CHECK-NEXT: $d0 = COPY undef %1:fpr64
14+
; CHECK-NEXT: BL @foo, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit killed $d0, implicit-def $sp
15+
; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp
16+
; CHECK-NEXT: MSRpstatesvcrImm1 1, 0, csr_aarch64_smstartstop, implicit-def dead $nzcv, implicit $vg, implicit-def $vg, implicit-def $fpmr
17+
; CHECK-NEXT: RET_ReallyLR
18+
entry:
19+
tail call void @foo(double poison) "aarch64_pstate_sm_enabled"
20+
ret void
21+
}

0 commit comments

Comments
 (0)