Skip to content

Commit 632cbee

Browse files
authored
[RISCV] Use VM and VMNoV0 for "vr" and "vd" inline asm constraints with mask type. (#171235)
The inline assembly handling in SelectionDAG uses the first type for the register class as the type at the input/output of the inlineassembly. If this isn't the type for the surrounding DAG, it needs to be converted. nxv8i8 is the first type for the VR and VRNoV0 register classes. So we currently generate insert/extract_subvector and bitcasts to convert to/from nxv8i8. I believe some of the special casing we have for this in splitValueIntoRegisterParts and joinRegisterPartsIntoValue is causing us to also generate incorrect code for arguments with nxv16i4 types that should be any extended to nxv16i8. Instead we widen them to nxv32i4 and bitcast to nxv16i8. This patch uses VM and VMNoV0 for masks which has nxv64i1 as their first type. This means we will only emit an insert/extract_subvector without any bitcasts. This will allow me to fix splitValueIntoRegisterParts and joinRegisterPartsIntoValue to fix the nxv16i4 argument issue without breaking inline assembly. I may need to add more register classes to cover fractional LMULs, but I'm not sure yet.
1 parent 2e16f24 commit 632cbee

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24323,14 +24323,15 @@ RISCVTargetLowering::getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,
2432324323
break;
2432424324
}
2432524325
} else if (Constraint == "vr") {
24326+
// Check VM first so that mask types will use that instead of VR.
2432624327
for (const auto *RC :
24327-
{&RISCV::VRRegClass, &RISCV::VRM2RegClass, &RISCV::VRM4RegClass,
24328-
&RISCV::VRM8RegClass, &RISCV::VRN2M1RegClass, &RISCV::VRN3M1RegClass,
24329-
&RISCV::VRN4M1RegClass, &RISCV::VRN5M1RegClass,
24330-
&RISCV::VRN6M1RegClass, &RISCV::VRN7M1RegClass,
24331-
&RISCV::VRN8M1RegClass, &RISCV::VRN2M2RegClass,
24332-
&RISCV::VRN3M2RegClass, &RISCV::VRN4M2RegClass,
24333-
&RISCV::VRN2M4RegClass}) {
24328+
{&RISCV::VMRegClass, &RISCV::VRRegClass, &RISCV::VRM2RegClass,
24329+
&RISCV::VRM4RegClass, &RISCV::VRM8RegClass, &RISCV::VRN2M1RegClass,
24330+
&RISCV::VRN3M1RegClass, &RISCV::VRN4M1RegClass,
24331+
&RISCV::VRN5M1RegClass, &RISCV::VRN6M1RegClass,
24332+
&RISCV::VRN7M1RegClass, &RISCV::VRN8M1RegClass,
24333+
&RISCV::VRN2M2RegClass, &RISCV::VRN3M2RegClass,
24334+
&RISCV::VRN4M2RegClass, &RISCV::VRN2M4RegClass}) {
2433424335
if (TRI->isTypeLegalForClass(*RC, VT.SimpleTy))
2433524336
return std::make_pair(0U, RC);
2433624337

@@ -24341,15 +24342,16 @@ RISCVTargetLowering::getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,
2434124342
}
2434224343
}
2434324344
} else if (Constraint == "vd") {
24345+
// Check VMNoV0 first so that mask types will use that instead of VRNoV0.
2434424346
for (const auto *RC :
24345-
{&RISCV::VRNoV0RegClass, &RISCV::VRM2NoV0RegClass,
24346-
&RISCV::VRM4NoV0RegClass, &RISCV::VRM8NoV0RegClass,
24347-
&RISCV::VRN2M1NoV0RegClass, &RISCV::VRN3M1NoV0RegClass,
24348-
&RISCV::VRN4M1NoV0RegClass, &RISCV::VRN5M1NoV0RegClass,
24349-
&RISCV::VRN6M1NoV0RegClass, &RISCV::VRN7M1NoV0RegClass,
24350-
&RISCV::VRN8M1NoV0RegClass, &RISCV::VRN2M2NoV0RegClass,
24351-
&RISCV::VRN3M2NoV0RegClass, &RISCV::VRN4M2NoV0RegClass,
24352-
&RISCV::VRN2M4NoV0RegClass}) {
24347+
{&RISCV::VMNoV0RegClass, &RISCV::VRNoV0RegClass,
24348+
&RISCV::VRM2NoV0RegClass, &RISCV::VRM4NoV0RegClass,
24349+
&RISCV::VRM8NoV0RegClass, &RISCV::VRN2M1NoV0RegClass,
24350+
&RISCV::VRN3M1NoV0RegClass, &RISCV::VRN4M1NoV0RegClass,
24351+
&RISCV::VRN5M1NoV0RegClass, &RISCV::VRN6M1NoV0RegClass,
24352+
&RISCV::VRN7M1NoV0RegClass, &RISCV::VRN8M1NoV0RegClass,
24353+
&RISCV::VRN2M2NoV0RegClass, &RISCV::VRN3M2NoV0RegClass,
24354+
&RISCV::VRN4M2NoV0RegClass, &RISCV::VRN2M4NoV0RegClass}) {
2435324355
if (TRI->isTypeLegalForClass(*RC, VT.SimpleTy))
2435424356
return std::make_pair(0U, RC);
2435524357

0 commit comments

Comments
 (0)