| Index: src/compiler/graph-reducer.cc
|
| diff --git a/src/compiler/graph-reducer.cc b/src/compiler/graph-reducer.cc
|
| index b13b9547140fcc69952abaa7037c8d7fb63cee7b..9f550c9eb8a5418123f80a896e44c44ccb11cfa9 100644
|
| --- a/src/compiler/graph-reducer.cc
|
| +++ b/src/compiler/graph-reducer.cc
|
| @@ -115,15 +115,25 @@ void GraphReducer::ReduceTop() {
|
|
|
| // Recurse on an input if necessary.
|
| int start = entry.input_index < node->InputCount() ? entry.input_index : 0;
|
| - for (int i = start; i < node->InputCount(); i++) {
|
| - Node* input = node->InputAt(i);
|
| - entry.input_index = i + 1;
|
| - if (input != node && Recurse(input)) return;
|
| +
|
| + Node::Inputs node_inputs = node->inputs();
|
| + auto node_inputs_begin = node_inputs.begin();
|
| + auto node_inputs_end = node_inputs.end();
|
| + DCHECK(node_inputs_end == node_inputs_begin + node->InputCount());
|
| +
|
| + for (auto it = node_inputs_begin + start; it != node_inputs_end; ++it) {
|
| + Node* input = *it;
|
| + if (input != node && Recurse(input)) {
|
| + entry.input_index = (it - node_inputs_begin) + 1;
|
| + return;
|
| + }
|
| }
|
| - for (int i = 0; i < start; i++) {
|
| - Node* input = node->InputAt(i);
|
| - entry.input_index = i + 1;
|
| - if (input != node && Recurse(input)) return;
|
| + for (auto it = node_inputs_begin; it != node_inputs_begin + start; ++it) {
|
| + Node* input = *it;
|
| + if (input != node && Recurse(input)) {
|
| + entry.input_index = (it - node_inputs_begin) + 1;
|
| + return;
|
| + }
|
| }
|
|
|
| // Remember the max node id before reduction.
|
| @@ -139,10 +149,15 @@ void GraphReducer::ReduceTop() {
|
| Node* const replacement = reduction.replacement();
|
| if (replacement == node) {
|
| // In-place update of {node}, may need to recurse on an input.
|
| - for (int i = 0; i < node->InputCount(); ++i) {
|
| - Node* input = node->InputAt(i);
|
| - entry.input_index = i + 1;
|
| - if (input != node && Recurse(input)) return;
|
| + Node::Inputs node_inputs = node->inputs();
|
| + auto node_inputs_begin = node_inputs.begin();
|
| + auto node_inputs_end = node_inputs.end();
|
| + for (auto it = node_inputs_begin; it != node_inputs_end; ++it) {
|
| + Node* input = *it;
|
| + if (input != node && Recurse(input)) {
|
| + entry.input_index = (it - node_inputs_begin) + 1;
|
| + return;
|
| + }
|
| }
|
| }
|
|
|
|
|