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

Unified Diff: runtime/vm/redundancy_elimination.cc

Issue 1918913002: VM: Improve phi-elimination to improve code inside of try-catch. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: added TODO Created 4 years, 8 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/intermediate_language.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/redundancy_elimination.cc
diff --git a/runtime/vm/redundancy_elimination.cc b/runtime/vm/redundancy_elimination.cc
index adc131995d27c87fd9ca5f9c5cdd683056dbd1af..b24f5587034aef0d0c247bcd11cb2ac28fba37f8 100644
--- a/runtime/vm/redundancy_elimination.cc
+++ b/runtime/vm/redundancy_elimination.cc
@@ -2347,6 +2347,8 @@ class LoadOptimizer : public ValueObject {
// Insert the given phi into the graph. Attempt to find an equal one in the
// target block first.
// Returns true if the phi was inserted and false if it was replaced.
+ // TODO(fschneider): Generalize this to allow replacing a phi with a non-phi
+ // definition as well so that we don't need Phi::HasReplacement anymore.
bool EmitPhi(PhiInstr* phi) {
for (PhiIterator it(phi->block()); !it.Done(); it.Advance()) {
if (ReplacePhiWith(phi, it.Current())) {
@@ -3437,6 +3439,7 @@ void DeadCodeElimination::EliminateDeadPhis(FlowGraph* flow_graph) {
for (intptr_t i = 0; i < join->phis_->length(); ++i) {
PhiInstr* phi = (*join->phis_)[i];
if (phi != NULL) {
+ Definition* replacement = NULL;
if (!phi->is_alive()) {
phi->ReplaceUsesWith(flow_graph->constant_null());
phi->UnuseAllInputs();
@@ -3450,7 +3453,16 @@ void DeadCodeElimination::EliminateDeadPhis(FlowGraph* flow_graph) {
(*join->phis_)[i] = NULL;
if (FLAG_trace_optimization) {
THR_Print("Removing redundant phi v%" Pd "\n",
- phi->ssa_temp_index());
+ phi->ssa_temp_index());
+ }
+ } else if (phi->HasReplacement(&replacement)) {
+ phi->ReplaceUsesWith(replacement);
+ phi->UnuseAllInputs();
+ (*join->phis_)[i] = NULL;
+ if (FLAG_trace_optimization) {
+ THR_Print("Replace redundant phi v%" Pd " with v%" Pd "\n",
+ phi->ssa_temp_index(),
+ replacement->ssa_temp_index());
}
} else {
(*join->phis_)[to_index++] = phi;
« no previous file with comments | « runtime/vm/intermediate_language.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698