From: Krzysztof Parzyszek Date: Wed, 26 Feb 2020 16:54:18 +0000 (-0600) Subject: [SDAG] Add SDNode::values() = make_range(values_begin(), values_end()) X-Git-Tag: 2020.06-alpha~123^2~788 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fd7c2e24c1c2ae7d0e251a86cb026710c576eaac;p=platform%2Fupstream%2Fllvm.git [SDAG] Add SDNode::values() = make_range(values_begin(), values_end()) Also use it in a few places to simplify code a little bit. NFC --- diff --git a/llvm/include/llvm/CodeGen/SelectionDAGNodes.h b/llvm/include/llvm/CodeGen/SelectionDAGNodes.h index 086a54c0b078..faee8e8ffa17 100644 --- a/llvm/include/llvm/CodeGen/SelectionDAGNodes.h +++ b/llvm/include/llvm/CodeGen/SelectionDAGNodes.h @@ -1017,6 +1017,9 @@ public: value_iterator value_begin() const { return ValueList; } value_iterator value_end() const { return ValueList+NumValues; } + iterator_range values() const { + return llvm::make_range(value_begin(), value_end()); + } /// Return the opcode of this operation for printing. std::string getOperationName(const SelectionDAG *G = nullptr) const; diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp index a624228dac0d..4d923a3c84dc 100644 --- a/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp @@ -182,9 +182,7 @@ bool VectorLegalizer::Run() { E = std::prev(DAG.allnodes_end()); I != std::next(E); ++I) { // Check if the values of the nodes contain vectors. We don't need to check // the operands because we are going to check their values at some point. - for (SDNode::value_iterator J = I->value_begin(), E = I->value_end(); - J != E; ++J) - HasVectors |= J->isVector(); + HasVectors = llvm::any_of(I->values(), [](EVT T) { return T.isVector(); }); // If we found a vector node we can start the legalization. if (HasVectors) @@ -318,12 +316,10 @@ SDValue VectorLegalizer::LegalizeOp(SDValue Op) { } } - bool HasVectorValueOrOp = false; - for (auto J = Node->value_begin(), E = Node->value_end(); J != E; ++J) - HasVectorValueOrOp |= J->isVector(); - for (const SDValue &Oper : Node->op_values()) - HasVectorValueOrOp |= Oper.getValueType().isVector(); - + bool HasVectorValueOrOp = + llvm::any_of(Node->values(), [](EVT T) { return T.isVector(); }) || + llvm::any_of(Node->op_values(), + [](SDValue O) { return O.getValueType().isVector(); }); if (!HasVectorValueOrOp) return TranslateLegalizeResults(Op, Node); diff --git a/llvm/lib/Target/Mips/MipsSEISelLowering.cpp b/llvm/lib/Target/Mips/MipsSEISelLowering.cpp index 798e8784405f..bdf29c53cbd5 100644 --- a/llvm/lib/Target/Mips/MipsSEISelLowering.cpp +++ b/llvm/lib/Target/Mips/MipsSEISelLowering.cpp @@ -1342,9 +1342,8 @@ static SDValue lowerDSPIntr(SDValue Op, SelectionDAG &DAG, unsigned Opc) { // Scan output. SmallVector ResTys; - for (SDNode::value_iterator I = Op->value_begin(), E = Op->value_end(); - I != E; ++I) - ResTys.push_back((*I == MVT::i64) ? MVT::Untyped : *I); + for (EVT Ty : Op->values()) + ResTys.push_back((Ty == MVT::i64) ? MVT::Untyped : Ty); // Create node. SDValue Val = DAG.getNode(Opc, DL, ResTys, Ops);