Skip to content

Commit 31a571b

Browse files
committed
[AArch64PostCoalescer] Preserve COALESCER_BARRIER for active register uses
If the destination register still has active uses, removing COALESCER_BARRIER is unsafe.
1 parent 885d416 commit 31a571b

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

llvm/lib/Target/AArch64/AArch64PostCoalescerPass.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ bool AArch64PostCoalescer::runOnMachineFunction(MachineFunction &MF) {
7272
case AArch64::COALESCER_BARRIER_FPR128: {
7373
Register Src = MI.getOperand(1).getReg();
7474
Register Dst = MI.getOperand(0).getReg();
75+
if (MRI->hasOneDef(Dst) && !MRI->use_empty(Dst))
76+
continue;
7577
if (Src != Dst)
7678
MRI->replaceRegWith(Dst, Src);
7779

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
; RUN: llc -mtriple=aarch64 -mattr=+sme -stop-ater=aarch64-post-coalescer-pass < %s | FileCheck %s
2+
3+
; CHECK-LABEL: name: bar
4+
; CHECK: [[dst:%[0-9]+]]:fpr64 = COALESCER_BARRIER_FPR64 undef [[src:%[0-9]+]]
5+
6+
target triple = "aarch64"
7+
8+
declare void @foo(double) "aarch64_pstate_sm_enabled"
9+
10+
define dso_local void @bar(double noundef %a) local_unnamed_addr {
11+
entry:
12+
tail call void @foo(double poison) "aarch64_pstate_sm_enabled"
13+
ret void
14+
}

0 commit comments

Comments
 (0)