llvm.org GIT mirror llvm / 47eab8f
[DAGCombine] Cleanup visitEXTRACT_SUBVECTOR. NFCI. Use ArrayRef::slice, reduce some rather awkward long lines for legibility and run clang-format. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@359326 91177308-0d34-0410-b5e6-96231b3b80d8 Simon Pilgrim 1 year, 4 months ago
1 changed file(s) with 11 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
1753017530 return NewLd;
1753117531 }
1753217532
17533 SDValue DAGCombiner::visitEXTRACT_SUBVECTOR(SDNode* N) {
17533 SDValue DAGCombiner::visitEXTRACT_SUBVECTOR(SDNode *N) {
1753417534 EVT NVT = N->getValueType(0);
1753517535 SDValue V = N->getOperand(0);
1753617536
1758317583 if (ExtractSize % EltSize == 0) {
1758417584 unsigned NumElems = ExtractSize / EltSize;
1758517585 EVT EltVT = InVT.getVectorElementType();
17586 EVT ExtractVT = NumElems == 1 ? EltVT :
17587 EVT::getVectorVT(*DAG.getContext(), EltVT, NumElems);
17586 EVT ExtractVT = NumElems == 1 ? EltVT
17587 : EVT::getVectorVT(*DAG.getContext(),
17588 EltVT, NumElems);
1758817589 if ((Level < AfterLegalizeDAG ||
1758917590 (NumElems == 1 ||
1759017591 TLI.isOperationLegal(ISD::BUILD_VECTOR, ExtractVT))) &&
1759117592 (!LegalTypes || TLI.isTypeLegal(ExtractVT))) {
17592 unsigned IdxVal = (Idx->getZExtValue() * NVT.getScalarSizeInBits()) /
17593 EltSize;
17593 unsigned IdxVal = Idx->getZExtValue();
17594 IdxVal *= NVT.getScalarSizeInBits();
17595 IdxVal /= EltSize;
17596
1759417597 if (NumElems == 1) {
1759517598 SDValue Src = V->getOperand(IdxVal);
1759617599 if (EltVT != Src.getValueType())
1759717600 Src = DAG.getNode(ISD::TRUNCATE, SDLoc(N), InVT, Src);
17598
1759917601 return DAG.getBitcast(NVT, Src);
1760017602 }
1760117603
1760217604 // Extract the pieces from the original build_vector.
17603 SDValue BuildVec = DAG.getBuildVector(ExtractVT, SDLoc(N),
17604 makeArrayRef(V->op_begin() + IdxVal,
17605 NumElems));
17605 SDValue BuildVec = DAG.getBuildVector(
17606 ExtractVT, SDLoc(N), V->ops().slice(IdxVal, NumElems));
1760617607 return DAG.getBitcast(NVT, BuildVec);
1760717608 }
1760817609 }
1763217633 return DAG.getNode(
1763317634 ISD::EXTRACT_SUBVECTOR, SDLoc(N), NVT,
1763417635 DAG.getBitcast(N->getOperand(0).getValueType(), V.getOperand(0)),
17635 N->getOperand(1));
17636 N->getOperand(1));
1763617637 }
1763717638 }
1763817639