diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 4adea020011b8..d3cd9b1671e1b 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -12739,12 +12739,12 @@ static SDValue tryToFoldExtendSelectLoad(SDNode *N, const TargetLowering &TLI, /// dag nodes (see for example method DAGCombiner::visitSIGN_EXTEND). /// Vector extends are not folded if operations are legal; this is to /// avoid introducing illegal build_vector dag nodes. -static SDValue tryToFoldExtendOfConstant(SDNode *N, const TargetLowering &TLI, +static SDValue tryToFoldExtendOfConstant(SDNode *N, const SDLoc &DL, + const TargetLowering &TLI, SelectionDAG &DAG, bool LegalTypes) { unsigned Opcode = N->getOpcode(); SDValue N0 = N->getOperand(0); EVT VT = N->getValueType(0); - SDLoc DL(N); assert((ISD::isExtOpcode(Opcode) || ISD::isExtVecInRegOpcode(Opcode)) && "Expected EXTEND dag node in input!"); @@ -13400,7 +13400,7 @@ SDValue DAGCombiner::visitSIGN_EXTEND(SDNode *N) { if (N0.isUndef()) return DAG.getConstant(0, DL, VT); - if (SDValue Res = tryToFoldExtendOfConstant(N, TLI, DAG, LegalTypes)) + if (SDValue Res = tryToFoldExtendOfConstant(N, DL, TLI, DAG, LegalTypes)) return Res; // fold (sext (sext x)) -> (sext x) @@ -13669,7 +13669,7 @@ SDValue DAGCombiner::visitZERO_EXTEND(SDNode *N) { if (N0.isUndef()) return DAG.getConstant(0, DL, VT); - if (SDValue Res = tryToFoldExtendOfConstant(N, TLI, DAG, LegalTypes)) + if (SDValue Res = tryToFoldExtendOfConstant(N, DL, TLI, DAG, LegalTypes)) return Res; // fold (zext (zext x)) -> (zext x) @@ -13937,12 +13937,13 @@ SDValue DAGCombiner::visitZERO_EXTEND(SDNode *N) { SDValue DAGCombiner::visitANY_EXTEND(SDNode *N) { SDValue N0 = N->getOperand(0); EVT VT = N->getValueType(0); + SDLoc DL(N); // aext(undef) = undef if (N0.isUndef()) return DAG.getUNDEF(VT); - if (SDValue Res = tryToFoldExtendOfConstant(N, TLI, DAG, LegalTypes)) + if (SDValue Res = tryToFoldExtendOfConstant(N, DL, TLI, DAG, LegalTypes)) return Res; // fold (aext (aext x)) -> (aext x) @@ -13951,7 +13952,7 @@ SDValue DAGCombiner::visitANY_EXTEND(SDNode *N) { if (N0.getOpcode() == ISD::ANY_EXTEND || N0.getOpcode() == ISD::ZERO_EXTEND || N0.getOpcode() == ISD::SIGN_EXTEND) - return DAG.getNode(N0.getOpcode(), SDLoc(N), VT, N0.getOperand(0)); + return DAG.getNode(N0.getOpcode(), DL, VT, N0.getOperand(0)); // fold (aext (aext_extend_vector_inreg x)) -> (aext_extend_vector_inreg x) // fold (aext (zext_extend_vector_inreg x)) -> (zext_extend_vector_inreg x) @@ -13959,7 +13960,7 @@ SDValue DAGCombiner::visitANY_EXTEND(SDNode *N) { if (N0.getOpcode() == ISD::ANY_EXTEND_VECTOR_INREG || N0.getOpcode() == ISD::ZERO_EXTEND_VECTOR_INREG || N0.getOpcode() == ISD::SIGN_EXTEND_VECTOR_INREG) - return DAG.getNode(N0.getOpcode(), SDLoc(N), VT, N0.getOperand(0)); + return DAG.getNode(N0.getOpcode(), DL, VT, N0.getOperand(0)); // fold (aext (truncate (load x))) -> (aext (smaller load x)) // fold (aext (truncate (srl (load x), c))) -> (aext (small load (x+c/n))) @@ -13977,7 +13978,7 @@ SDValue DAGCombiner::visitANY_EXTEND(SDNode *N) { // fold (aext (truncate x)) if (N0.getOpcode() == ISD::TRUNCATE) - return DAG.getAnyExtOrTrunc(N0.getOperand(0), SDLoc(N), VT); + return DAG.getAnyExtOrTrunc(N0.getOperand(0), DL, VT); // Fold (aext (and (trunc x), cst)) -> (and x, cst) // if the trunc is not free. @@ -13985,7 +13986,6 @@ SDValue DAGCombiner::visitANY_EXTEND(SDNode *N) { N0.getOperand(0).getOpcode() == ISD::TRUNCATE && N0.getOperand(1).getOpcode() == ISD::Constant && !TLI.isTruncateFree(N0.getOperand(0).getOperand(0), N0.getValueType())) { - SDLoc DL(N); SDValue X = DAG.getAnyExtOrTrunc(N0.getOperand(0).getOperand(0), DL, VT); SDValue Y = DAG.getNode(ISD::ANY_EXTEND, DL, VT, N0.getOperand(1)); assert(isa(Y) && "Expected constant to be folded!"); @@ -14011,9 +14011,9 @@ SDValue DAGCombiner::visitANY_EXTEND(SDNode *N) { ExtendUsesToFormExtLoad(VT, N, N0, ISD::ANY_EXTEND, SetCCs, TLI); if (DoXform) { LoadSDNode *LN0 = cast(N0); - SDValue ExtLoad = DAG.getExtLoad(ISD::EXTLOAD, SDLoc(N), VT, - LN0->getChain(), LN0->getBasePtr(), - N0.getValueType(), LN0->getMemOperand()); + SDValue ExtLoad = DAG.getExtLoad(ISD::EXTLOAD, DL, VT, LN0->getChain(), + LN0->getBasePtr(), N0.getValueType(), + LN0->getMemOperand()); ExtendSetCCUses(SetCCs, N0, ExtLoad, ISD::ANY_EXTEND); // If the load value is used only by N, replace it via CombineTo N. bool NoReplaceTrunc = N0.hasOneUse(); @@ -14039,9 +14039,9 @@ SDValue DAGCombiner::visitANY_EXTEND(SDNode *N) { ISD::LoadExtType ExtType = LN0->getExtensionType(); EVT MemVT = LN0->getMemoryVT(); if (!LegalOperations || TLI.isLoadExtLegal(ExtType, VT, MemVT)) { - SDValue ExtLoad = DAG.getExtLoad(ExtType, SDLoc(N), - VT, LN0->getChain(), LN0->getBasePtr(), - MemVT, LN0->getMemOperand()); + SDValue ExtLoad = + DAG.getExtLoad(ExtType, DL, VT, LN0->getChain(), LN0->getBasePtr(), + MemVT, LN0->getMemOperand()); CombineTo(N, ExtLoad); DAG.ReplaceAllUsesOfValueWith(SDValue(LN0, 1), ExtLoad.getValue(1)); recursivelyDeleteUnusedNodes(LN0); @@ -14069,23 +14069,20 @@ SDValue DAGCombiner::visitANY_EXTEND(SDNode *N) { // we know that the element size of the sext'd result matches the // element size of the compare operands. if (VT.getSizeInBits() == N00VT.getSizeInBits()) - return DAG.getSetCC(SDLoc(N), VT, N0.getOperand(0), - N0.getOperand(1), - cast(N0.getOperand(2))->get()); + return DAG.getSetCC(DL, VT, N0.getOperand(0), N0.getOperand(1), + cast(N0.getOperand(2))->get()); // If the desired elements are smaller or larger than the source // elements we can use a matching integer vector type and then // truncate/any extend EVT MatchingVectorType = N00VT.changeVectorElementTypeToInteger(); - SDValue VsetCC = - DAG.getSetCC(SDLoc(N), MatchingVectorType, N0.getOperand(0), - N0.getOperand(1), - cast(N0.getOperand(2))->get()); - return DAG.getAnyExtOrTrunc(VsetCC, SDLoc(N), VT); + SDValue VsetCC = DAG.getSetCC( + DL, MatchingVectorType, N0.getOperand(0), N0.getOperand(1), + cast(N0.getOperand(2))->get()); + return DAG.getAnyExtOrTrunc(VsetCC, DL, VT); } // aext(setcc x,y,cc) -> select_cc x, y, 1, 0, cc - SDLoc DL(N); if (SDValue SCC = SimplifySelectCC( DL, N0.getOperand(0), N0.getOperand(1), DAG.getConstant(1, DL, VT), DAG.getConstant(0, DL, VT), @@ -14637,10 +14634,9 @@ SDValue DAGCombiner::visitSIGN_EXTEND_INREG(SDNode *N) { return SDValue(); } -static SDValue -foldExtendVectorInregToExtendOfSubvector(SDNode *N, const TargetLowering &TLI, - SelectionDAG &DAG, - bool LegalOperations) { +static SDValue foldExtendVectorInregToExtendOfSubvector( + SDNode *N, const SDLoc &DL, const TargetLowering &TLI, SelectionDAG &DAG, + bool LegalOperations) { unsigned InregOpcode = N->getOpcode(); unsigned Opcode = DAG.getOpcode_EXTEND(InregOpcode); @@ -14667,28 +14663,29 @@ foldExtendVectorInregToExtendOfSubvector(SDNode *N, const TargetLowering &TLI, if (LegalOperations && !TLI.isOperationLegal(Opcode, VT)) return SDValue(); - return DAG.getNode(Opcode, SDLoc(N), VT, Src); + return DAG.getNode(Opcode, DL, VT, Src); } SDValue DAGCombiner::visitEXTEND_VECTOR_INREG(SDNode *N) { SDValue N0 = N->getOperand(0); EVT VT = N->getValueType(0); + SDLoc DL(N); if (N0.isUndef()) { // aext_vector_inreg(undef) = undef because the top bits are undefined. // {s/z}ext_vector_inreg(undef) = 0 because the top bits must be the same. return N->getOpcode() == ISD::ANY_EXTEND_VECTOR_INREG ? DAG.getUNDEF(VT) - : DAG.getConstant(0, SDLoc(N), VT); + : DAG.getConstant(0, DL, VT); } - if (SDValue Res = tryToFoldExtendOfConstant(N, TLI, DAG, LegalTypes)) + if (SDValue Res = tryToFoldExtendOfConstant(N, DL, TLI, DAG, LegalTypes)) return Res; if (SimplifyDemandedVectorElts(SDValue(N, 0))) return SDValue(N, 0); - if (SDValue R = foldExtendVectorInregToExtendOfSubvector(N, TLI, DAG, + if (SDValue R = foldExtendVectorInregToExtendOfSubvector(N, DL, TLI, DAG, LegalOperations)) return R;