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

Unified Diff: sdk/lib/_internal/compiler/implementation/ssa/value_range_analyzer.dart

Issue 369833005: Fix range-analysis. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 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 | « no previous file | tests/language/range_analysis3_test.dart » ('j') | tests/language/range_analysis3_test.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/ssa/value_range_analyzer.dart
diff --git a/sdk/lib/_internal/compiler/implementation/ssa/value_range_analyzer.dart b/sdk/lib/_internal/compiler/implementation/ssa/value_range_analyzer.dart
index f58002930542c2b2d5ecb7d53e5696386a7f60cf..dc3f53ed12440bf1d3c90f986a5320d58c09d172 100644
--- a/sdk/lib/_internal/compiler/implementation/ssa/value_range_analyzer.dart
+++ b/sdk/lib/_internal/compiler/implementation/ssa/value_range_analyzer.dart
@@ -899,6 +899,20 @@ class SsaValueRangeAnalyzer extends HBaseVisitor implements OptimizationPhase {
}
}
+ static BinaryOperation mirrorOperation(BinaryOperation operation) {
Kevin Millikin (Google) 2014/07/07 14:23:31 'flipOperation'? Since mirrors is a thing in Dart
floitsch 2014/07/07 16:02:49 Done.
+ if (operation == const LessOperation()) {
+ return const GreaterOperation();
+ } else if (operation == const LessEqualOperation()) {
+ return const GreaterEqualOperation();
+ } else if (operation == const GreaterOperation()) {
+ return const LessOperation();
+ } else if (operation == const GreaterEqualOperation()) {
+ return const LessEqualOperation();
+ } else {
+ return null;
+ }
+ }
+
Range computeConstrainedRange(BinaryOperation operation,
Range leftRange,
Range rightRange) {
@@ -932,7 +946,7 @@ class SsaValueRangeAnalyzer extends HBaseVisitor implements OptimizationPhase {
Range rightRange = ranges[right];
Range leftRange = ranges[left];
Operation operation = condition.operation(constantSystem);
- Operation reverse = reverseOperation(operation);
+ Operation mirrorOp = mirrorOperation(operation);
// Only update the true branch if this block is the only
// predecessor.
if (branch.trueBranch.predecessors.length == 1) {
@@ -946,7 +960,7 @@ class SsaValueRangeAnalyzer extends HBaseVisitor implements OptimizationPhase {
ranges[instruction] = range;
}
- range = computeConstrainedRange(reverse, rightRange, leftRange);
+ range = computeConstrainedRange(mirrorOp, rightRange, leftRange);
if (rightRange != range) {
HInstruction instruction =
createRangeConversion(branch.trueBranch.first, right);
@@ -958,6 +972,8 @@ class SsaValueRangeAnalyzer extends HBaseVisitor implements OptimizationPhase {
// predecessor.
if (branch.falseBranch.predecessors.length == 1) {
assert(branch.falseBranch.predecessors[0] == branch.block);
+ Operation reverse = reverseOperation(operation);
+ Operation reversedMirror = mirrorOperation(reverse);
// Update the false branch to use narrower ranges for [left] and
// [right].
Range range = computeConstrainedRange(reverse, leftRange, rightRange);
@@ -967,7 +983,7 @@ class SsaValueRangeAnalyzer extends HBaseVisitor implements OptimizationPhase {
ranges[instruction] = range;
}
- range = computeConstrainedRange(operation, rightRange, leftRange);
+ range = computeConstrainedRange(reversedMirror, rightRange, leftRange);
if (rightRange != range) {
HInstruction instruction =
createRangeConversion(branch.falseBranch.first, right);
« no previous file with comments | « no previous file | tests/language/range_analysis3_test.dart » ('j') | tests/language/range_analysis3_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698