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

Unified Diff: pkg/compiler/lib/src/cps_ir/shrinking_reductions.dart

Issue 1620873003: dart2js cps: Tolerate refinements in more cases. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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 | « pkg/compiler/lib/src/cps_ir/redundant_phi.dart ('k') | pkg/compiler/lib/src/js_backend/codegen/task.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/cps_ir/shrinking_reductions.dart
diff --git a/pkg/compiler/lib/src/cps_ir/shrinking_reductions.dart b/pkg/compiler/lib/src/cps_ir/shrinking_reductions.dart
index 830579af327de555c6a49ef4b3a6965acd0eb26a..0eecbe127cc965c1fbb00300a1a29f9539c3319e 100644
--- a/pkg/compiler/lib/src/cps_ir/shrinking_reductions.dart
+++ b/pkg/compiler/lib/src/cps_ir/shrinking_reductions.dart
@@ -403,6 +403,16 @@ bool _isEtaCont(Continuation cont) {
return true;
}
+Expression _unfoldDeadRefinements(Expression node) {
+ while (node is LetPrim) {
+ LetPrim let = node;
+ Primitive prim = let.primitive;
+ if (prim.hasAtLeastOneUse || prim is! Refinement) return node;
+ node = node.next;
+ }
+ return node;
+}
+
bool _isBranchTargetOfUselessIf(Continuation cont) {
// A useless-if has an empty then and else branch, e.g. `if (cond);`.
//
@@ -416,13 +426,16 @@ bool _isBranchTargetOfUselessIf(Continuation cont) {
if (!cont.hasExactlyOneUse) return false;
if (cont.firstRef.parent is! Branch) return false;
Branch branch = cont.firstRef.parent;
+
+ // Are both continuations the same InvokeContinuation on a join?
Continuation trueCont = branch.trueContinuation.definition;
+ Expression trueBody = _unfoldDeadRefinements(trueCont.body);
+ if (trueBody is! InvokeContinuation) return false;
Continuation falseCont = branch.falseContinuation.definition;
- // Are both continuations the same InvokeContinuation on a join?
- if (trueCont.body is! InvokeContinuation) return false;
- if (falseCont.body is! InvokeContinuation) return false;
- InvokeContinuation trueInvoke = trueCont.body;
- InvokeContinuation falseInvoke = falseCont.body;
+ Expression falseBody = _unfoldDeadRefinements(falseCont.body);
+ if (falseBody is! InvokeContinuation) return false;
+ InvokeContinuation trueInvoke = trueBody;
+ InvokeContinuation falseInvoke = falseBody;
if (trueInvoke.continuation.definition !=
falseInvoke.continuation.definition) {
return false;
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/redundant_phi.dart ('k') | pkg/compiler/lib/src/js_backend/codegen/task.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698