Skip to content

Commit

Permalink
[RISCV] Make getDefaultVLOps call getDefaultScalableVLOps instead of …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
topperc committed Nov 16, 2023
1 parent c79ffb0 commit 8404406
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions llvm/lib/Target/RISCV/RISCVISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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,
Expand Down

0 comments on commit 8404406

Please sign in to comment.