[llvm] r359326 - [DAGCombine] Cleanup visitEXTRACT_SUBVECTOR. NFCI.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 26 10:49:02 PDT 2019
Author: rksimon
Date: Fri Apr 26 10:49:02 2019
New Revision: 359326
URL: http://llvm.org/viewvc/llvm-project?rev=359326&view=rev
Log:
[DAGCombine] Cleanup visitEXTRACT_SUBVECTOR. NFCI.
Use ArrayRef::slice, reduce some rather awkward long lines for legibility and run clang-format.
Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=359326&r1=359325&r2=359326&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Fri Apr 26 10:49:02 2019
@@ -17531,7 +17531,7 @@ static SDValue narrowExtractedVectorLoad
return NewLd;
}
-SDValue DAGCombiner::visitEXTRACT_SUBVECTOR(SDNode* N) {
+SDValue DAGCombiner::visitEXTRACT_SUBVECTOR(SDNode *N) {
EVT NVT = N->getValueType(0);
SDValue V = N->getOperand(0);
@@ -17584,26 +17584,27 @@ SDValue DAGCombiner::visitEXTRACT_SUBVEC
if (ExtractSize % EltSize == 0) {
unsigned NumElems = ExtractSize / EltSize;
EVT EltVT = InVT.getVectorElementType();
- EVT ExtractVT = NumElems == 1 ? EltVT :
- EVT::getVectorVT(*DAG.getContext(), EltVT, NumElems);
+ EVT ExtractVT = NumElems == 1 ? EltVT
+ : EVT::getVectorVT(*DAG.getContext(),
+ EltVT, NumElems);
if ((Level < AfterLegalizeDAG ||
(NumElems == 1 ||
TLI.isOperationLegal(ISD::BUILD_VECTOR, ExtractVT))) &&
(!LegalTypes || TLI.isTypeLegal(ExtractVT))) {
- unsigned IdxVal = (Idx->getZExtValue() * NVT.getScalarSizeInBits()) /
- EltSize;
+ unsigned IdxVal = Idx->getZExtValue();
+ IdxVal *= NVT.getScalarSizeInBits();
+ IdxVal /= EltSize;
+
if (NumElems == 1) {
SDValue Src = V->getOperand(IdxVal);
if (EltVT != Src.getValueType())
Src = DAG.getNode(ISD::TRUNCATE, SDLoc(N), InVT, Src);
-
return DAG.getBitcast(NVT, Src);
}
// Extract the pieces from the original build_vector.
- SDValue BuildVec = DAG.getBuildVector(ExtractVT, SDLoc(N),
- makeArrayRef(V->op_begin() + IdxVal,
- NumElems));
+ SDValue BuildVec = DAG.getBuildVector(
+ ExtractVT, SDLoc(N), V->ops().slice(IdxVal, NumElems));
return DAG.getBitcast(NVT, BuildVec);
}
}
@@ -17633,7 +17634,7 @@ SDValue DAGCombiner::visitEXTRACT_SUBVEC
return DAG.getNode(
ISD::EXTRACT_SUBVECTOR, SDLoc(N), NVT,
DAG.getBitcast(N->getOperand(0).getValueType(), V.getOperand(0)),
- N->getOperand(1));
+ N->getOperand(1));
}
}
More information about the llvm-commits
mailing list