Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Unified Diff: src/compiler/graph-reducer.cc

Issue 2585713002: [turbofan] Use Node input iterators where possible (Closed)
Patch Set: Use == instead of DCHECK_EQ because of missing operator<< for iterators Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/escape-analysis-reducer.cc ('k') | src/compiler/node.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
+ }
}
}
« no previous file with comments | « src/compiler/escape-analysis-reducer.cc ('k') | src/compiler/node.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698