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

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

Issue 758953002: cps-ir: Optimize identical used with constants. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add an assert. Created 6 years, 1 month 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 | « no previous file | tests/compiler/dart2js/js_backend_cps_ir_control_flow.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/constant_propagation.dart
diff --git a/pkg/compiler/lib/src/cps_ir/constant_propagation.dart b/pkg/compiler/lib/src/cps_ir/constant_propagation.dart
index daadc5be55bc3d349502d3a5fd014ee564c18977..fcf5c1b8bb482cf7e31a748ef1afb5b0aba3b3a2 100644
--- a/pkg/compiler/lib/src/cps_ir/constant_propagation.dart
+++ b/pkg/compiler/lib/src/cps_ir/constant_propagation.dart
@@ -607,7 +607,23 @@ class _ConstPropagationVisitor extends Visitor {
// JavaScript specific nodes.
void visitIdentical(Identical node) {
- setValue(node, _ConstnessLattice.NonConst);
+ _ConstnessLattice leftConst = getValue(node.left.definition);
karlklose 2014/11/26 08:16:00 Indentation is correct, the highlighting hides the
+ _ConstnessLattice rightConst = getValue(node.left.definition);
+ ConstantValue leftValue = leftConst.constant;
+ ConstantValue rightValue = rightConst.constant;
+ if (leftConst.isUnknown || rightConst.isUnknown) {
+ // Come back later.
+ return;
+ } else if (!leftConst.isConstant || !rightConst.isConstant) {
+ setValue(node, _ConstnessLattice.NonConst);
+ } else if (leftValue.isPrimitive && rightValue.isPrimitive) {
+ assert(leftConst.isConstant && rightConst.isConstant);
+ PrimitiveConstantValue left = leftValue;
+ PrimitiveConstantValue right = rightValue;
+ ConstantValue result =
+ new BoolConstantValue(left.primitiveValue == right.primitiveValue);
+ setValue(node, new _ConstnessLattice(result));
+ }
}
}
« no previous file with comments | « no previous file | tests/compiler/dart2js/js_backend_cps_ir_control_flow.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698