Skip to content

Commit 0d328e3

Browse files
authored
[AArch64][SME] Use PNR Reg classes for predicate constraint (llvm#67606)
This patch fixes an error where ASM with constraints cannot select SME instructions which use the top eight predicate-as-counter registers.
1 parent b34f15d commit 0d328e3

File tree

2 files changed

+36
-4
lines changed

2 files changed

+36
-4
lines changed

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10052,18 +10052,21 @@ static PredicateConstraint parsePredicateConstraint(StringRef Constraint) {
1005210052

1005310053
static const TargetRegisterClass *
1005410054
getPredicateRegisterClass(PredicateConstraint Constraint, EVT VT) {
10055-
if (!VT.isScalableVector() || VT.getVectorElementType() != MVT::i1)
10055+
if (VT != MVT::aarch64svcount &&
10056+
(!VT.isScalableVector() || VT.getVectorElementType() != MVT::i1))
1005610057
return nullptr;
1005710058

1005810059
switch (Constraint) {
1005910060
default:
1006010061
return nullptr;
1006110062
case PredicateConstraint::Uph:
10062-
return &AArch64::PPR_p8to15RegClass;
10063+
return VT == MVT::aarch64svcount ? &AArch64::PNR_p8to15RegClass
10064+
: &AArch64::PPR_p8to15RegClass;
1006310065
case PredicateConstraint::Upl:
10064-
return &AArch64::PPR_3bRegClass;
10066+
return VT == MVT::aarch64svcount ? nullptr : &AArch64::PPR_3bRegClass;
1006510067
case PredicateConstraint::Upa:
10066-
return &AArch64::PPRRegClass;
10068+
return VT == MVT::aarch64svcount ? &AArch64::PNRRegClass
10069+
: &AArch64::PPRRegClass;
1006710070
}
1006810071
}
1006910072

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
; RUN: llc < %s -mtriple aarch64-none-linux-gnu -mattr=+sme2 -stop-after=finalize-isel | FileCheck %s
2+
3+
define dso_local void @UphPNR(target("aarch64.svcount") %predcnt) {
4+
entry:
5+
; CHECK: %0:ppr = COPY $p0
6+
; CHECK: STR_PXI %0, %stack.0.predcnt.addr, 0 :: (store unknown-size into %ir.predcnt.addr, align 2)
7+
; CHECK: %1:pnr_p8to15 = COPY %0
8+
; CHECK: INLINEASM &"ld1w {z0.s,z1.s,z2.s,z3.s}, $0/z, [x10]", 1 /* sideeffect attdialect */, 393225 /* reguse:PNR_p8to15 */, %1
9+
; CHECK: RET_ReallyLR
10+
%predcnt.addr = alloca target("aarch64.svcount"), align 2
11+
store target("aarch64.svcount") %predcnt, ptr %predcnt.addr, align 2
12+
%0 = load target("aarch64.svcount"), ptr %predcnt.addr, align 2
13+
call void asm sideeffect "ld1w {z0.s,z1.s,z2.s,z3.s}, $0/z, [x10]", "@3Uph"(target("aarch64.svcount") %0)
14+
ret void
15+
}
16+
17+
define dso_local void @UpaPNR(target("aarch64.svcount") %predcnt) {
18+
entry:
19+
; CHECK: %0:ppr = COPY $p0
20+
; CHECK: STR_PXI %0, %stack.0.predcnt.addr, 0 :: (store unknown-size into %ir.predcnt.addr, align 2)
21+
; CHECK: %1:pnr = COPY %0
22+
; CHECK: INLINEASM &"ld1w {z0.s,z1.s,z2.s,z3.s}, $0/z, [x10]", 1 /* sideeffect attdialect */, 262153 /* reguse:PNR */, %1
23+
; CHECK: RET_ReallyLR
24+
%predcnt.addr = alloca target("aarch64.svcount"), align 2
25+
store target("aarch64.svcount") %predcnt, ptr %predcnt.addr, align 2
26+
%0 = load target("aarch64.svcount"), ptr %predcnt.addr, align 2
27+
call void asm sideeffect "ld1w {z0.s,z1.s,z2.s,z3.s}, $0/z, [x10]", "@3Upa"(target("aarch64.svcount") %0)
28+
ret void
29+
}

0 commit comments

Comments
 (0)