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

Unified Diff: runtime/vm/flow_graph_optimizer.cc

Issue 11824024: Constant propagator should revisit phis when it visits predecessor block. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 | « runtime/vm/flow_graph_optimizer.h ('k') | tests/language/constant_propagation_phis_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/flow_graph_optimizer.cc
diff --git a/runtime/vm/flow_graph_optimizer.cc b/runtime/vm/flow_graph_optimizer.cc
index 358c2122de2b8148f94bfed9f1053675b45390f1..39a1d22f8e0e81629632a34473b84c84a94025dd 100644
--- a/runtime/vm/flow_graph_optimizer.cc
+++ b/runtime/vm/flow_graph_optimizer.cc
@@ -3663,18 +3663,12 @@ void ConstantPropagator::VisitGraphEntry(GraphEntryInstr* block) {
void ConstantPropagator::VisitJoinEntry(JoinEntryInstr* block) {
- ZoneGrowableArray<PhiInstr*>* phis = block->phis();
- if (phis != NULL) {
- for (intptr_t phi_idx = 0; phi_idx < phis->length(); ++phi_idx) {
- PhiInstr* phi = (*phis)[phi_idx];
- if (phi == NULL) continue;
- phi->Accept(this);
- }
- }
-
+ // Phis are visited when visiting predecessor. See VisitSuccessorPhis.
for (ForwardInstructionIterator it(block); !it.Done(); it.Advance()) {
it.Current()->Accept(this);
}
+
+ VisitSuccessorPhis(block);
}
@@ -3682,6 +3676,8 @@ void ConstantPropagator::VisitTargetEntry(TargetEntryInstr* block) {
for (ForwardInstructionIterator it(block); !it.Done(); it.Advance()) {
it.Current()->Accept(this);
}
+
+ VisitSuccessorPhis(block);
}
@@ -3691,6 +3687,18 @@ void ConstantPropagator::VisitParallelMove(ParallelMoveInstr* instr) {
}
+void ConstantPropagator::VisitSuccessorPhis(BlockEntryInstr* block) {
+ // Phi value depends on the reachability of a predecessor. We have
+ // to revisit phis every time a predecessor becomes reachable.
+ GotoInstr* goto_instr = block->last_instruction()->AsGoto();
+ if (goto_instr != NULL) {
+ for (PhiIterator it(goto_instr->successor()); !it.Done(); it.Advance()) {
+ it.Current()->Accept(this);
+ }
+ }
+}
+
+
// --------------------------------------------------------------------------
// Analysis of control instructions. Unconditional successors are
// reachable. Conditional successors are reachable depending on the
« no previous file with comments | « runtime/vm/flow_graph_optimizer.h ('k') | tests/language/constant_propagation_phis_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698