Skip to content

Commit e42e97a

Browse files
[AArch64][SME] Don't mark 'smstart za' as using/defining VG. (#84775)
VG is only used/defined when changing the streaming mode, using 'smstart sm' or plainly 'smstart' (same for smstop).
1 parent 0be9592 commit e42e97a

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7751,14 +7751,24 @@ void AArch64TargetLowering::AdjustInstrPostInstrSelection(MachineInstr &MI,
77517751
// register allocator to pass call args in callee saved regs, without extra
77527752
// copies to avoid these fake clobbers of actually-preserved GPRs.
77537753
if (MI.getOpcode() == AArch64::MSRpstatesvcrImm1 ||
7754-
MI.getOpcode() == AArch64::MSRpstatePseudo)
7754+
MI.getOpcode() == AArch64::MSRpstatePseudo) {
77557755
for (unsigned I = MI.getNumOperands() - 1; I > 0; --I)
77567756
if (MachineOperand &MO = MI.getOperand(I);
77577757
MO.isReg() && MO.isImplicit() && MO.isDef() &&
77587758
(AArch64::GPR32RegClass.contains(MO.getReg()) ||
77597759
AArch64::GPR64RegClass.contains(MO.getReg())))
77607760
MI.removeOperand(I);
77617761

7762+
// The SVE vector length can change when entering/leaving streaming mode.
7763+
if (MI.getOperand(0).getImm() == AArch64SVCR::SVCRSM ||
7764+
MI.getOperand(0).getImm() == AArch64SVCR::SVCRSMZA) {
7765+
MI.addOperand(MachineOperand::CreateReg(AArch64::VG, /*IsDef=*/false,
7766+
/*IsImplicit=*/true));
7767+
MI.addOperand(MachineOperand::CreateReg(AArch64::VG, /*IsDef=*/true,
7768+
/*IsImplicit=*/true));
7769+
}
7770+
}
7771+
77627772
// Add an implicit use of 'VG' for ADDXri/SUBXri, which are instructions that
77637773
// have nothing to do with VG, were it not that they are used to materialise a
77647774
// frame-address. If they contain a frame-index to a scalable vector, this

llvm/lib/Target/AArch64/SMEInstrFormats.td

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,6 @@ def MSRpstatesvcrImm1
223223
let Inst{8} = imm;
224224
let Inst{7-5} = 0b011; // op2
225225
let hasPostISelHook = 1;
226-
let Uses = [VG];
227-
let Defs = [VG];
228226
}
229227

230228
def : InstAlias<"smstart", (MSRpstatesvcrImm1 0b011, 0b1)>;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
; RUN: llc -mattr=+sme -stop-after=finalize-isel < %s | FileCheck %s
2+
3+
target triple = "aarch64"
4+
5+
; Check that we don't define VG for 'smstart za' and 'smstop za'
6+
define void @smstart_za() "aarch64_new_za" nounwind {
7+
; CHECK-LABEL: name: smstart_za
8+
; CHECK-NOT: implicit-def {{[^,]*}}$vg
9+
ret void
10+
}
11+
12+
; Check that we do define VG for 'smstart sm' and 'smstop sm'
13+
define void @smstart_sm() nounwind {
14+
; CHECK-LABEL: name: smstart_sm
15+
; CHECK: MSRpstatesvcrImm1 1, 1,
16+
; CHECK-SAME: implicit-def {{[^,]*}}$vg
17+
; CHECK: MSRpstatesvcrImm1 1, 0,
18+
; CHECK-SAME: implicit-def {{[^,]*}}$vg
19+
call void @require_sm()
20+
ret void
21+
}
22+
23+
declare void @require_sm() "aarch64_pstate_sm_enabled"
24+
declare void @require_za() "aarch64_inout_za"

0 commit comments

Comments
 (0)