From: Sanjay Patel Date: Fri, 10 May 2019 20:02:30 +0000 (+0000) Subject: [DAGCombiner] reduce code duplication; NFC X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=354c14e139d7a5719fbd869eb2077025ad7fd48b;p=llvm [DAGCombiner] reduce code duplication; NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360462 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 59f7af01e8b..61176bf624a 100644 --- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -17573,9 +17573,9 @@ SDValue DAGCombiner::visitEXTRACT_SUBVECTOR(SDNode *N) { // Combine an extract of an extract into a single extract_subvector. // ext (ext X, C), 0 --> ext X, C - if (isNullConstant(N->getOperand(1)) && - V.getOpcode() == ISD::EXTRACT_SUBVECTOR && V.hasOneUse() && - isa(V.getOperand(1))) { + SDValue Index = N->getOperand(1); + if (isNullConstant(Index) && V.getOpcode() == ISD::EXTRACT_SUBVECTOR && + V.hasOneUse() && isa(V.getOperand(1))) { if (TLI.isExtractSubvectorCheap(NVT, V.getOperand(0).getValueType(), V.getConstantOperandVal(1)) && TLI.isOperationLegalOrCustom(ISD::EXTRACT_SUBVECTOR, NVT)) { @@ -17590,8 +17590,7 @@ SDValue DAGCombiner::visitEXTRACT_SUBVECTOR(SDNode *N) { // Vi if possible // Only operand 0 is checked as 'concat' assumes all inputs of the same // type. - if (V.getOpcode() == ISD::CONCAT_VECTORS && - isa(N->getOperand(1)) && + if (V.getOpcode() == ISD::CONCAT_VECTORS && isa(Index) && V.getOperand(0).getValueType() == NVT) { unsigned Idx = N->getConstantOperandVal(1); unsigned NumElems = NVT.getVectorNumElements(); @@ -17604,7 +17603,7 @@ SDValue DAGCombiner::visitEXTRACT_SUBVECTOR(SDNode *N) { // If the input is a build vector. Try to make a smaller build vector. if (V.getOpcode() == ISD::BUILD_VECTOR) { - if (auto *Idx = dyn_cast(N->getOperand(1))) { + if (auto *IdxC = dyn_cast(Index)) { EVT InVT = V.getValueType(); unsigned ExtractSize = NVT.getSizeInBits(); unsigned EltSize = InVT.getScalarSizeInBits(); @@ -17619,7 +17618,7 @@ SDValue DAGCombiner::visitEXTRACT_SUBVECTOR(SDNode *N) { (NumElems == 1 || TLI.isOperationLegal(ISD::BUILD_VECTOR, ExtractVT))) && (!LegalTypes || TLI.isTypeLegal(ExtractVT))) { - unsigned IdxVal = Idx->getZExtValue(); + unsigned IdxVal = IdxC->getZExtValue(); IdxVal *= NVT.getScalarSizeInBits(); IdxVal /= EltSize; @@ -17647,9 +17646,8 @@ SDValue DAGCombiner::visitEXTRACT_SUBVECTOR(SDNode *N) { return SDValue(); // Only handle cases where both indexes are constants. - auto *ExtIdx = dyn_cast(N->getOperand(1)); + auto *ExtIdx = dyn_cast(Index); auto *InsIdx = dyn_cast(V.getOperand(2)); - if (InsIdx && ExtIdx) { // Combine: // (extract_subvec (insert_subvec V1, V2, InsIdx), ExtIdx) @@ -17662,7 +17660,7 @@ SDValue DAGCombiner::visitEXTRACT_SUBVECTOR(SDNode *N) { return DAG.getNode( ISD::EXTRACT_SUBVECTOR, SDLoc(N), NVT, DAG.getBitcast(N->getOperand(0).getValueType(), V.getOperand(0)), - N->getOperand(1)); + Index); } }