| Index: pkg/compiler/lib/src/tree_ir/optimization/statement_rewriter.dart
|
| diff --git a/pkg/compiler/lib/src/tree_ir/optimization/statement_rewriter.dart b/pkg/compiler/lib/src/tree_ir/optimization/statement_rewriter.dart
|
| index 721f99098cdadb054f098ff958a89c7326a42961..61f0a3121de4010b2290fd73e3800ca95af61d52 100644
|
| --- a/pkg/compiler/lib/src/tree_ir/optimization/statement_rewriter.dart
|
| +++ b/pkg/compiler/lib/src/tree_ir/optimization/statement_rewriter.dart
|
| @@ -37,8 +37,8 @@ part of tree_ir.optimization;
|
| * environment and the definition is recursively processed (in the
|
| * new environment at the use site) before being propagated.
|
| *
|
| - * See [visitVariable] for the implementation of the heuristic for propagating
|
| - * a definition.
|
| + * See [visitVariableUse] for the implementation of the heuristic for
|
| + * propagating a definition.
|
| *
|
| *
|
| * IF-TO-CONDITIONAL CONVERSION:
|
| @@ -165,9 +165,10 @@ class StatementRewriter extends Visitor<Statement, Expression> with PassMixin {
|
|
|
| Expression visitExpression(Expression e) => e.processed ? e : e.accept(this);
|
|
|
| - Expression visitVariable(Variable node) {
|
| + @override
|
| + Expression visitVariableUse(VariableUse node) {
|
| // Propagate constant to use site.
|
| - Expression constant = constantEnvironment[node];
|
| + Expression constant = constantEnvironment[node.variable];
|
| if (constant != null) return constant;
|
|
|
| // Propagate a variable's definition to its use site if:
|
| @@ -176,10 +177,11 @@ class StatementRewriter extends Visitor<Statement, Expression> with PassMixin {
|
| // 2. It was the most recent expression evaluated so that we do not
|
| // reorder expressions with side effects.
|
| if (!environment.isEmpty &&
|
| - environment.last.variable == node &&
|
| + environment.last.variable == node.variable &&
|
| environment.last.hasExactlyOneUse) {
|
| return visitExpression(environment.removeLast().definition);
|
| }
|
| +
|
| // If the definition could not be propagated, leave the variable use.
|
| return node;
|
| }
|
| @@ -193,7 +195,7 @@ class StatementRewriter extends Visitor<Statement, Expression> with PassMixin {
|
| return exp is Constant ||
|
| exp is This ||
|
| exp is ReifyTypeVar ||
|
| - exp is Variable && constantEnvironment.containsKey(exp);
|
| + exp is VariableUse && constantEnvironment.containsKey(exp.variable);
|
| }
|
|
|
| Statement visitAssign(Assign node) {
|
| @@ -558,8 +560,8 @@ class StatementRewriter extends Visitor<Statement, Expression> with PassMixin {
|
| /// If non-null is returned, the caller must discard [e1] and [e2] and use
|
| /// the resulting expression in the tree.
|
| static Expression combineExpressions(Expression e1, Expression e2) {
|
| - if (e1 is Variable && e1 == e2) {
|
| - --e1.readCount; // Two references become one.
|
| + if (e1 is VariableUse && e2 is VariableUse && e1.variable == e2.variable) {
|
| + --e1.variable.readCount; // Two references become one.
|
| return e1;
|
| }
|
| if (e1 is Constant && e2 is Constant && e1.value == e2.value) {
|
|
|