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

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: Address comments. 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') | no next file with comments »
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..15f460bfaf4a23a31c768e6a37ac1c49b1f4f08a 100644
--- a/sdk/lib/_internal/compiler/implementation/ssa/value_range_analyzer.dart
+++ b/sdk/lib/_internal/compiler/implementation/ssa/value_range_analyzer.dart
@@ -774,7 +774,7 @@ class SsaValueRangeAnalyzer extends HBaseVisitor implements OptimizationPhase {
relational.block.rewrite(
relational, graph.addConstantBool(true, compiler));
relational.block.remove(relational);
- } else if (reverseOperation(operation).apply(leftRange, rightRange)) {
+ } else if (negateOperation(operation).apply(leftRange, rightRange)) {
relational.block.rewrite(
relational, graph.addConstantBool(false, compiler));
relational.block.remove(relational);
@@ -885,7 +885,7 @@ class SsaValueRangeAnalyzer extends HBaseVisitor implements OptimizationPhase {
return newInstruction;
}
- static BinaryOperation reverseOperation(BinaryOperation operation) {
+ static BinaryOperation negateOperation(BinaryOperation operation) {
if (operation == const LessOperation()) {
return const GreaterEqualOperation();
} else if (operation == const LessEqualOperation()) {
@@ -899,6 +899,20 @@ class SsaValueRangeAnalyzer extends HBaseVisitor implements OptimizationPhase {
}
}
+ static BinaryOperation flipOperation(BinaryOperation operation) {
+ 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 = flipOperation(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 = negateOperation(operation);
+ Operation reversedMirror = flipOperation(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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698