From 84044061e880bd6c7994cb2e3048a073cf76a683 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Wed, 15 Nov 2023 19:12:26 -0800 Subject: [PATCH] [RISCV] Make getDefaultVLOps call getDefaultScalableVLOps instead of the other way around. NFC Previously getDefaultScalableVLOps called getDefaultVLOps. getDefaultVLOps also handles fixed vectors so had to then check if it was fixed or scalable. Since getDefaultScalableVLOps know the type is scalable, it makes sense for it to contain the scalable case directly and have getDefaultVLOps call it for the scalable case. --- llvm/lib/Target/RISCV/RISCVISelLowering.cpp | 22 ++++++++++----------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp index 55ef4bd5a4e4bd..fc0f59a09315b7 100644 --- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp +++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp @@ -2584,6 +2584,15 @@ static SDValue getVLOp(uint64_t NumElts, const SDLoc &DL, SelectionDAG &DAG, return DAG.getConstant(NumElts, DL, Subtarget.getXLenVT()); } +static std::pair +getDefaultScalableVLOps(MVT VecVT, const SDLoc &DL, SelectionDAG &DAG, + const RISCVSubtarget &Subtarget) { + assert(VecVT.isScalableVector() && "Expecting a scalable vector"); + SDValue VL = DAG.getRegister(RISCV::X0, Subtarget.getXLenVT()); + SDValue Mask = getAllOnesMask(VecVT, VL, DL, DAG); + return {Mask, VL}; +} + static std::pair getDefaultVLOps(uint64_t NumElts, MVT ContainerVT, const SDLoc &DL, SelectionDAG &DAG, const RISCVSubtarget &Subtarget) { @@ -2604,18 +2613,7 @@ getDefaultVLOps(MVT VecVT, MVT ContainerVT, const SDLoc &DL, SelectionDAG &DAG, return getDefaultVLOps(VecVT.getVectorNumElements(), ContainerVT, DL, DAG, Subtarget); assert(ContainerVT.isScalableVector() && "Expecting scalable container type"); - MVT XLenVT = Subtarget.getXLenVT(); - SDValue VL = DAG.getRegister(RISCV::X0, XLenVT); - SDValue Mask = getAllOnesMask(ContainerVT, VL, DL, DAG); - return {Mask, VL}; -} - -// As above but assuming the given type is a scalable vector type. -static std::pair -getDefaultScalableVLOps(MVT VecVT, const SDLoc &DL, SelectionDAG &DAG, - const RISCVSubtarget &Subtarget) { - assert(VecVT.isScalableVector() && "Expecting a scalable vector"); - return getDefaultVLOps(VecVT, VecVT, DL, DAG, Subtarget); + return getDefaultScalableVLOps(ContainerVT, DL, DAG, Subtarget); } SDValue RISCVTargetLowering::computeVLMax(MVT VecVT, const SDLoc &DL,