[llvm] 1e30bf8 - [SelectionDAG] Add an overload of getStepVector that assumes step 1.
Eli Friedman via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 14 11:37:52 PDT 2021
Author: Eli Friedman
Date: 2021-07-14T11:37:01-07:00
New Revision: 1e30bf8621cc123a7afba3246a36187c5ce3c836
URL: https://github.com/llvm/llvm-project/commit/1e30bf8621cc123a7afba3246a36187c5ce3c836
DIFF: https://github.com/llvm/llvm-project/commit/1e30bf8621cc123a7afba3246a36187c5ce3c836.diff
LOG: [SelectionDAG] Add an overload of getStepVector that assumes step 1.
This is mostly a minor convenience, but the pattern seems frequent
enough to be worthwhile (and we'll probably add more uses in the
future).
Differential Revision: https://reviews.llvm.org/D105850
Added:
Modified:
llvm/include/llvm/CodeGen/SelectionDAG.h
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/CodeGen/SelectionDAG.h b/llvm/include/llvm/CodeGen/SelectionDAG.h
index 5e12da6791add..8cbdf7e023854 100644
--- a/llvm/include/llvm/CodeGen/SelectionDAG.h
+++ b/llvm/include/llvm/CodeGen/SelectionDAG.h
@@ -837,6 +837,10 @@ class SelectionDAG {
/// <0, Step, Step * 2, Step * 3, ...>
SDValue getStepVector(const SDLoc &DL, EVT ResVT, SDValue Step);
+ /// Returns a vector of type ResVT whose elements contain the linear sequence
+ /// <0, 1, 2, 3, ...>
+ SDValue getStepVector(const SDLoc &DL, EVT ResVT);
+
/// Returns an ISD::VECTOR_SHUFFLE node semantically equivalent to
/// the shuffle node in input but with swapped operands.
///
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 0dbcfefaedcdb..e194e1b328e60 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -1747,6 +1747,11 @@ SDValue SelectionDAG::getCondCode(ISD::CondCode Cond) {
return SDValue(CondCodeNodes[Cond], 0);
}
+SDValue SelectionDAG::getStepVector(const SDLoc &DL, EVT ResVT) {
+ EVT OpVT = TLI->getTypeToTransformTo(*getContext(), ResVT.getScalarType());
+ return getStepVector(DL, ResVT, getConstant(1, DL, OpVT));
+}
+
SDValue SelectionDAG::getStepVector(const SDLoc &DL, EVT ResVT, SDValue Step) {
if (ResVT.isScalableVector())
return getNode(ISD::STEP_VECTOR, DL, ResVT, Step);
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index 58e691aade9ca..d56d4bcc91693 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -11074,10 +11074,7 @@ void SelectionDAGBuilder::visitStepVector(const CallInst &I) {
const TargetLowering &TLI = DAG.getTargetLoweringInfo();
auto DL = getCurSDLoc();
EVT ResultVT = TLI.getValueType(DAG.getDataLayout(), I.getType());
- EVT OpVT =
- TLI.getTypeToTransformTo(*DAG.getContext(), ResultVT.getScalarType());
- SDValue Step = DAG.getConstant(1, DL, OpVT);
- setValue(&I, DAG.getStepVector(DL, ResultVT, Step));
+ setValue(&I, DAG.getStepVector(DL, ResultVT));
}
void SelectionDAGBuilder::visitVectorReverse(const CallInst &I) {
diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index 7bc73a9b8fce9..8cda50d1298df 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -9503,7 +9503,7 @@ SDValue AArch64TargetLowering::LowerDUPQLane(SDValue Op,
SDValue SplatOne = DAG.getNode(ISD::SPLAT_VECTOR, DL, MVT::nxv2i64, One);
// create the vector 0,1,0,1,...
- SDValue SV = DAG.getNode(ISD::STEP_VECTOR, DL, MVT::nxv2i64, One);
+ SDValue SV = DAG.getStepVector(DL, MVT::nxv2i64);
SV = DAG.getNode(ISD::AND, DL, MVT::nxv2i64, SV, SplatOne);
// create the vector idx64,idx64+1,idx64,idx64+1,...
@@ -13998,9 +13998,7 @@ static SDValue LowerSVEIntrinsicIndex(SDNode *N, SelectionDAG &DAG) {
ScalarTy = MVT::i32;
// Lower index_vector(base, step) to mul(step step_vector(1)) + splat(base).
- SDValue One = DAG.getConstant(1, DL, ScalarTy);
- SDValue StepVector =
- DAG.getNode(ISD::STEP_VECTOR, DL, N->getValueType(0), One);
+ SDValue StepVector = DAG.getStepVector(DL, N->getValueType(0));
SDValue Step = DAG.getNode(ISD::SPLAT_VECTOR, DL, N->getValueType(0), Op2);
SDValue Mul = DAG.getNode(ISD::MUL, DL, N->getValueType(0), StepVector, Step);
SDValue Base = DAG.getNode(ISD::SPLAT_VECTOR, DL, N->getValueType(0), Op1);
More information about the llvm-commits
mailing list