| 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;
|
|
|