[llvm] f1720ab - [RISCV] Cleanup some places that assumed VLMaxSentinel and -1 constant mean the same thing. NFCI
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 2 12:23:36 PST 2022
Author: Craig Topper
Date: 2022-02-02T12:23:12-08:00
New Revision: f1720abb5464e38585e0ce6ccf19d8f164cf464c
URL: https://github.com/llvm/llvm-project/commit/f1720abb5464e38585e0ce6ccf19d8f164cf464c
DIFF: https://github.com/llvm/llvm-project/commit/f1720abb5464e38585e0ce6ccf19d8f164cf464c.diff
LOG: [RISCV] Cleanup some places that assumed VLMaxSentinel and -1 constant mean the same thing. NFCI
VLMaxSentintel happens to be represented as -1 TargetConstant. A user
provided -1 would be an ISD::Constant. We shouldn't assume that they
are the same thing. I'm still not entirely convinced that we should be
treating -1 from the user as VLMAX.
Also fix one place that failed to use XLenVT for the VLMaxSentinel,
using MVT::i64 in code that only executes on RV32.
Added:
Modified:
llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp b/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
index 6f77428ae7210..69d838775efeb 100644
--- a/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
@@ -1871,10 +1871,12 @@ bool RISCVDAGToDAGISel::hasAllNBitUsers(SDNode *Node, unsigned Bits) const {
// allows us to choose betwen VSETIVLI or VSETVLI later.
bool RISCVDAGToDAGISel::selectVLOp(SDValue N, SDValue &VL) {
auto *C = dyn_cast<ConstantSDNode>(N);
- if (C && (isUInt<5>(C->getZExtValue()) ||
- C->getSExtValue() == RISCV::VLMaxSentinel))
+ if (C && isUInt<5>(C->getZExtValue()))
VL = CurDAG->getTargetConstant(C->getZExtValue(), SDLoc(N),
N->getValueType(0));
+ else if (C && C->isAllOnesValue() && C->getOpcode() != ISD::TargetConstant)
+ VL = CurDAG->getTargetConstant(RISCV::VLMaxSentinel, SDLoc(N),
+ N->getValueType(0));
else
VL = N;
diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index 73f89ce676530..070a8064324d7 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -2284,14 +2284,17 @@ static SDValue splatPartsI64WithVL(const SDLoc &DL, MVT VT, SDValue Lo,
if ((LoC >> 31) == HiC)
return DAG.getNode(RISCVISD::VMV_V_X_VL, DL, VT, Lo, VL);
- // If vl is equal to VLMax and Hi constant is equal to Lo, we could use
+ // If vl is equal to XLEN_MAX and Hi constant is equal to Lo, we could use
// vmv.v.x whose EEW = 32 to lower it.
auto *Const = dyn_cast<ConstantSDNode>(VL);
- if (LoC == HiC && Const && Const->getSExtValue() == RISCV::VLMaxSentinel) {
+ if (LoC == HiC && Const && Const->isAllOnesValue() &&
+ Const->getOpcode() != ISD::TargetConstant) {
MVT InterVT = MVT::getVectorVT(MVT::i32, VT.getVectorElementCount() * 2);
// TODO: if vl <= min(VLMAX), we can also do this. But we could not
// access the subtarget here now.
- auto InterVec = DAG.getNode(RISCVISD::VMV_V_X_VL, DL, InterVT, Lo, VL);
+ auto InterVec = DAG.getNode(
+ RISCVISD::VMV_V_X_VL, DL, InterVT, Lo,
+ DAG.getTargetConstant(RISCV::VLMaxSentinel, DL, MVT::i32));
return DAG.getNode(ISD::BITCAST, DL, VT, InterVec);
}
}
@@ -4062,7 +4065,7 @@ SDValue RISCVTargetLowering::lowerSPLAT_VECTOR_PARTS(SDValue Op,
// Fall back to use a stack store and stride x0 vector load. Use X0 as VL.
return DAG.getNode(RISCVISD::SPLAT_VECTOR_SPLIT_I64_VL, DL, VecVT, Lo, Hi,
- DAG.getTargetConstant(RISCV::VLMaxSentinel, DL, MVT::i64));
+ DAG.getTargetConstant(RISCV::VLMaxSentinel, DL, MVT::i32));
}
// Custom-lower extensions from mask vectors by using a vselect either with 1
More information about the llvm-commits
mailing list