Skip to content

Commit fd7c2e2

Browse files
author
Krzysztof Parzyszek
committed
[SDAG] Add SDNode::values() = make_range(values_begin(), values_end())
Also use it in a few places to simplify code a little bit. NFC
1 parent 4f71252 commit fd7c2e2

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

llvm/include/llvm/CodeGen/SelectionDAGNodes.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,6 +1017,9 @@ END_TWO_BYTE_PACK()
10171017

10181018
value_iterator value_begin() const { return ValueList; }
10191019
value_iterator value_end() const { return ValueList+NumValues; }
1020+
iterator_range<value_iterator> values() const {
1021+
return llvm::make_range(value_begin(), value_end());
1022+
}
10201023

10211024
/// Return the opcode of this operation for printing.
10221025
std::string getOperationName(const SelectionDAG *G = nullptr) const;

llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,7 @@ bool VectorLegalizer::Run() {
182182
E = std::prev(DAG.allnodes_end()); I != std::next(E); ++I) {
183183
// Check if the values of the nodes contain vectors. We don't need to check
184184
// the operands because we are going to check their values at some point.
185-
for (SDNode::value_iterator J = I->value_begin(), E = I->value_end();
186-
J != E; ++J)
187-
HasVectors |= J->isVector();
185+
HasVectors = llvm::any_of(I->values(), [](EVT T) { return T.isVector(); });
188186

189187
// If we found a vector node we can start the legalization.
190188
if (HasVectors)
@@ -318,12 +316,10 @@ SDValue VectorLegalizer::LegalizeOp(SDValue Op) {
318316
}
319317
}
320318

321-
bool HasVectorValueOrOp = false;
322-
for (auto J = Node->value_begin(), E = Node->value_end(); J != E; ++J)
323-
HasVectorValueOrOp |= J->isVector();
324-
for (const SDValue &Oper : Node->op_values())
325-
HasVectorValueOrOp |= Oper.getValueType().isVector();
326-
319+
bool HasVectorValueOrOp =
320+
llvm::any_of(Node->values(), [](EVT T) { return T.isVector(); }) ||
321+
llvm::any_of(Node->op_values(),
322+
[](SDValue O) { return O.getValueType().isVector(); });
327323
if (!HasVectorValueOrOp)
328324
return TranslateLegalizeResults(Op, Node);
329325

llvm/lib/Target/Mips/MipsSEISelLowering.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,9 +1342,8 @@ static SDValue lowerDSPIntr(SDValue Op, SelectionDAG &DAG, unsigned Opc) {
13421342
// Scan output.
13431343
SmallVector<EVT, 2> ResTys;
13441344

1345-
for (SDNode::value_iterator I = Op->value_begin(), E = Op->value_end();
1346-
I != E; ++I)
1347-
ResTys.push_back((*I == MVT::i64) ? MVT::Untyped : *I);
1345+
for (EVT Ty : Op->values())
1346+
ResTys.push_back((Ty == MVT::i64) ? MVT::Untyped : Ty);
13481347

13491348
// Create node.
13501349
SDValue Val = DAG.getNode(Opc, DL, ResTys, Ops);

0 commit comments

Comments
 (0)