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

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

Issue 859053002: [turbofan] Pull ResizeMergeOrPhi into CommonOperatorBuilder and use in ControlReducer. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 11 months 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/common-operator.cc ('k') | src/compiler/loop-peeling.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/control-reducer.cc
diff --git a/src/compiler/control-reducer.cc b/src/compiler/control-reducer.cc
index ebddfc01e872839bbb8cfac3d8504f619fe721bc..d34b4e8dcec7f207ee9a7f03ef8aff0cda0b9606 100644
--- a/src/compiler/control-reducer.cc
+++ b/src/compiler/control-reducer.cc
@@ -509,28 +509,24 @@ class ControlReducerImpl {
// Remove inputs to {node} corresponding to the dead inputs to {merge}
// and compact the remaining inputs, updating the operator.
void RemoveDeadInputs(Node* merge, Node* node) {
- int pos = 0;
- for (int i = 0; i < node->InputCount(); i++) {
+ int live = 0;
+ for (int i = 0; i < merge->InputCount(); i++) {
// skip dead inputs.
- if (i < merge->InputCount() &&
- merge->InputAt(i)->opcode() == IrOpcode::kDead)
- continue;
+ if (merge->InputAt(i)->opcode() == IrOpcode::kDead) continue;
// compact live inputs.
- if (pos != i) node->ReplaceInput(pos, node->InputAt(i));
- pos++;
+ if (live != i) node->ReplaceInput(live, node->InputAt(i));
+ live++;
}
- node->TrimInputCount(pos);
- if (node->opcode() == IrOpcode::kPhi) {
- node->set_op(common_->Phi(OpParameter<MachineType>(node->op()), pos - 1));
- } else if (node->opcode() == IrOpcode::kEffectPhi) {
- node->set_op(common_->EffectPhi(pos - 1));
- } else if (node->opcode() == IrOpcode::kMerge) {
- node->set_op(common_->Merge(pos));
- } else if (node->opcode() == IrOpcode::kLoop) {
- node->set_op(common_->Loop(pos));
- } else {
- UNREACHABLE();
+ // compact remaining inputs.
+ int total = live;
+ for (int i = merge->InputCount(); i < node->InputCount(); i++) {
+ if (total != i) node->ReplaceInput(total, node->InputAt(i));
+ total++;
}
+ DCHECK_EQ(total, live + node->InputCount() - merge->InputCount());
+ DCHECK_NE(total, node->InputCount());
+ node->TrimInputCount(total);
+ node->set_op(common_->ResizeMergeOrPhi(node->op(), live));
}
// Replace uses of {node} with {replacement} and revisit the uses.
« no previous file with comments | « src/compiler/common-operator.cc ('k') | src/compiler/loop-peeling.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698