Skip to content

Commit d537075

Browse files
committed
[RISCV] Remove RISCVISD::VLE_VL/VSE_VL. Use intrinsics instead.
Similar to what we do for other loads/stores, use the intrinsic version that we already have custom isel for. Reviewed By: rogfer01 Differential Revision: https://reviews.llvm.org/D121166
1 parent 7cd78da commit d537075

File tree

3 files changed

+21
-48
lines changed

3 files changed

+21
-48
lines changed

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5664,15 +5664,23 @@ RISCVTargetLowering::lowerFixedLengthVectorLoadToRVV(SDValue Op,
56645664
"Expecting a correctly-aligned load");
56655665

56665666
MVT VT = Op.getSimpleValueType();
5667+
MVT XLenVT = Subtarget.getXLenVT();
56675668
MVT ContainerVT = getContainerForFixedLengthVector(VT);
56685669

5669-
SDValue VL =
5670-
DAG.getConstant(VT.getVectorNumElements(), DL, Subtarget.getXLenVT());
5670+
SDValue VL = DAG.getConstant(VT.getVectorNumElements(), DL, XLenVT);
56715671

5672+
bool IsMaskOp = VT.getVectorElementType() == MVT::i1;
5673+
SDValue IntID = DAG.getTargetConstant(
5674+
IsMaskOp ? Intrinsic::riscv_vlm : Intrinsic::riscv_vle, DL, XLenVT);
5675+
SmallVector<SDValue, 4> Ops{Load->getChain(), IntID};
5676+
if (!IsMaskOp)
5677+
Ops.push_back(DAG.getUNDEF(ContainerVT));
5678+
Ops.push_back(Load->getBasePtr());
5679+
Ops.push_back(VL);
56725680
SDVTList VTs = DAG.getVTList({ContainerVT, MVT::Other});
5673-
SDValue NewLoad = DAG.getMemIntrinsicNode(
5674-
RISCVISD::VLE_VL, DL, VTs, {Load->getChain(), Load->getBasePtr(), VL},
5675-
Load->getMemoryVT(), Load->getMemOperand());
5681+
SDValue NewLoad =
5682+
DAG.getMemIntrinsicNode(ISD::INTRINSIC_W_CHAIN, DL, VTs, Ops,
5683+
Load->getMemoryVT(), Load->getMemOperand());
56765684

56775685
SDValue Result = convertFromScalableVector(VT, NewLoad, DAG, Subtarget);
56785686
return DAG.getMergeValues({Result, Load->getChain()}, DL);
@@ -5691,6 +5699,7 @@ RISCVTargetLowering::lowerFixedLengthVectorStoreToRVV(SDValue Op,
56915699

56925700
SDValue StoreVal = Store->getValue();
56935701
MVT VT = StoreVal.getSimpleValueType();
5702+
MVT XLenVT = Subtarget.getXLenVT();
56945703

56955704
// If the size less than a byte, we need to pad with zeros to make a byte.
56965705
if (VT.getVectorElementType() == MVT::i1 && VT.getVectorNumElements() < 8) {
@@ -5702,14 +5711,17 @@ RISCVTargetLowering::lowerFixedLengthVectorStoreToRVV(SDValue Op,
57025711

57035712
MVT ContainerVT = getContainerForFixedLengthVector(VT);
57045713

5705-
SDValue VL =
5706-
DAG.getConstant(VT.getVectorNumElements(), DL, Subtarget.getXLenVT());
5714+
SDValue VL = DAG.getConstant(VT.getVectorNumElements(), DL, XLenVT);
57075715

57085716
SDValue NewValue =
57095717
convertToScalableVector(ContainerVT, StoreVal, DAG, Subtarget);
5718+
5719+
bool IsMaskOp = VT.getVectorElementType() == MVT::i1;
5720+
SDValue IntID = DAG.getTargetConstant(
5721+
IsMaskOp ? Intrinsic::riscv_vsm : Intrinsic::riscv_vse, DL, XLenVT);
57105722
return DAG.getMemIntrinsicNode(
5711-
RISCVISD::VSE_VL, DL, DAG.getVTList(MVT::Other),
5712-
{Store->getChain(), NewValue, Store->getBasePtr(), VL},
5723+
ISD::INTRINSIC_VOID, DL, DAG.getVTList(MVT::Other),
5724+
{Store->getChain(), IntID, NewValue, Store->getBasePtr(), VL},
57135725
Store->getMemoryVT(), Store->getMemOperand());
57145726
}
57155727

@@ -10826,8 +10838,6 @@ const char *RISCVTargetLowering::getTargetNodeName(unsigned Opcode) const {
1082610838
NODE_NAME_CASE(VSEXT_VL)
1082710839
NODE_NAME_CASE(VZEXT_VL)
1082810840
NODE_NAME_CASE(VCPOP_VL)
10829-
NODE_NAME_CASE(VLE_VL)
10830-
NODE_NAME_CASE(VSE_VL)
1083110841
NODE_NAME_CASE(READ_CSR)
1083210842
NODE_NAME_CASE(WRITE_CSR)
1083310843
NODE_NAME_CASE(SWAP_CSR)

llvm/lib/Target/RISCV/RISCVISelLowering.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -311,10 +311,6 @@ enum NodeType : unsigned {
311311
STRICT_FCVT_W_RV64 = ISD::FIRST_TARGET_STRICTFP_OPCODE,
312312
STRICT_FCVT_WU_RV64,
313313

314-
// Memory opcodes start here.
315-
VLE_VL = ISD::FIRST_TARGET_MEMORY_OPCODE,
316-
VSE_VL,
317-
318314
// WARNING: Do not add anything in the end unless you want the node to
319315
// have memop! In fact, starting from FIRST_TARGET_MEMORY_OPCODE all
320316
// opcodes will be thought as target memory ops!

llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@
2121
// Helpers to define the VL patterns.
2222
//===----------------------------------------------------------------------===//
2323

24-
def SDT_RISCVVLE_VL : SDTypeProfile<1, 2, [SDTCisVec<0>, SDTCisPtrTy<1>,
25-
SDTCisVT<2, XLenVT>]>;
26-
def SDT_RISCVVSE_VL : SDTypeProfile<0, 3, [SDTCisVec<0>, SDTCisPtrTy<1>,
27-
SDTCisVT<2, XLenVT>]>;
28-
2924
def SDT_RISCVIntBinOp_VL : SDTypeProfile<1, 4, [SDTCisSameAs<0, 1>,
3025
SDTCisSameAs<0, 2>,
3126
SDTCisVec<0>, SDTCisInt<0>,
@@ -66,11 +61,6 @@ def riscv_vfmv_s_f_vl : SDNode<"RISCVISD::VFMV_S_F_VL",
6661
SDTCisEltOfVec<2, 0>,
6762
SDTCisVT<3, XLenVT>]>>;
6863

69-
def riscv_vle_vl : SDNode<"RISCVISD::VLE_VL", SDT_RISCVVLE_VL,
70-
[SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
71-
def riscv_vse_vl : SDNode<"RISCVISD::VSE_VL", SDT_RISCVVSE_VL,
72-
[SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
73-
7464
def riscv_add_vl : SDNode<"RISCVISD::ADD_VL", SDT_RISCVIntBinOp_VL, [SDNPCommutative]>;
7565
def riscv_sub_vl : SDNode<"RISCVISD::SUB_VL", SDT_RISCVIntBinOp_VL>;
7666
def riscv_mul_vl : SDNode<"RISCVISD::MUL_VL", SDT_RISCVIntBinOp_VL, [SDNPCommutative]>;
@@ -745,29 +735,6 @@ multiclass VPatWidenReductionVL_Ext_VL<SDNode vop, PatFrags extop, string instru
745735

746736
let Predicates = [HasVInstructions] in {
747737

748-
// 7.4. Vector Unit-Stride Instructions
749-
foreach vti = AllVectors in {
750-
defvar load_instr = !cast<Instruction>("PseudoVLE"#vti.SEW#"_V_"#vti.LMul.MX);
751-
defvar store_instr = !cast<Instruction>("PseudoVSE"#vti.SEW#"_V_"#vti.LMul.MX);
752-
// Load
753-
def : Pat<(vti.Vector (riscv_vle_vl BaseAddr:$rs1, VLOpFrag)),
754-
(load_instr BaseAddr:$rs1, GPR:$vl, vti.Log2SEW)>;
755-
// Store
756-
def : Pat<(riscv_vse_vl (vti.Vector vti.RegClass:$rs2), BaseAddr:$rs1,
757-
VLOpFrag),
758-
(store_instr vti.RegClass:$rs2, BaseAddr:$rs1, GPR:$vl, vti.Log2SEW)>;
759-
}
760-
761-
foreach mti = AllMasks in {
762-
defvar load_instr = !cast<Instruction>("PseudoVLM_V_"#mti.BX);
763-
defvar store_instr = !cast<Instruction>("PseudoVSM_V_"#mti.BX);
764-
def : Pat<(mti.Mask (riscv_vle_vl BaseAddr:$rs1, VLOpFrag)),
765-
(load_instr BaseAddr:$rs1, GPR:$vl, mti.Log2SEW)>;
766-
def : Pat<(riscv_vse_vl (mti.Mask VR:$rs2), BaseAddr:$rs1,
767-
VLOpFrag),
768-
(store_instr VR:$rs2, BaseAddr:$rs1, GPR:$vl, mti.Log2SEW)>;
769-
}
770-
771738
// 12.1. Vector Single-Width Integer Add and Subtract
772739
defm : VPatBinaryVL_VV_VX_VI<riscv_add_vl, "PseudoVADD">;
773740
defm : VPatBinaryVL_VV_VX<riscv_sub_vl, "PseudoVSUB">;

0 commit comments

Comments
 (0)