[llvm] 8404406 - [RISCV] Make getDefaultVLOps call getDefaultScalableVLOps instead of the other way around. NFC

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 15 19:29:24 PST 2023


Author: Craig Topper
Date: 2023-11-15T19:28:00-08:00
New Revision: 84044061e880bd6c7994cb2e3048a073cf76a683

URL: https://github.com/llvm/llvm-project/commit/84044061e880bd6c7994cb2e3048a073cf76a683
DIFF: https://github.com/llvm/llvm-project/commit/84044061e880bd6c7994cb2e3048a073cf76a683.diff

LOG: [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.

Added: 
    

Modified: 
    llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index 55ef4bd5a4e4bdb..fc0f59a09315b76 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<SDValue, SDValue>
+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<SDValue, SDValue>
 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<SDValue, SDValue>
-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,


        


More information about the llvm-commits mailing list