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

Unified Diff: tests/compiler/dart2js/value_range2_test.dart

Issue 11066053: Better value range propagation by supporting negating ranges. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 2 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 | « lib/compiler/implementation/ssa/value_range_analyzer.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/value_range2_test.dart
===================================================================
--- tests/compiler/dart2js/value_range2_test.dart (revision 13354)
+++ tests/compiler/dart2js/value_range2_test.dart (working copy)
@@ -42,13 +42,33 @@
}
checkSubRange(Range one, Range two, [lower, upper]) {
+
+ buildBound(one, two) {
+ // Create a bound just like our current implementation in dart2js does.
+ if (two is IntValue) {
+ if (two.isNegative()) {
+ return new AddValue(one, -two);
+ } else if (two.isZero()) {
+ return one;
+ }
+ }
+ if (one is IntValue) {
+ if (one.isNegative()) {
+ return new SubtractValue(-two, -one);
+ } else if (one.isZero()) {
+ return -two;
+ }
+ }
+ return new SubtractValue(one, two);
+ }
+
if (lower == null) {
- lower = new OperationValue(one.lower, two.upper, const SubtractOperation());
+ lower = buildBound(one.lower, two.upper);
} else if (lower is num) {
lower = new IntValue(lower);
}
if (upper == null) {
- upper = new OperationValue(one.upper, two.lower, const SubtractOperation());
+ upper = buildBound(one.upper, two.lower);
} else if (upper is num) {
upper = new IntValue(upper);
}
@@ -56,6 +76,43 @@
Expect.equals(new Range(lower, upper), one - two);
}
+checkNegateRange(Range range, [arg1, arg2]) {
+ if (arg1 is Range) {
+ Expect.equals(arg1, -range);
+ } else {
+ Value low, up;
+ if (arg1 is num) {
+ low = new IntValue(arg1);
+ } else if (arg1 == null) {
+ low = new NegateValue(range.upper);
+ } else {
+ low = arg1;
+ }
+ if (arg2 is num) {
+ up = new IntValue(arg2);
+ } else if (arg2 == null) {
+ up = new NegateValue(range.lower);
+ } else {
+ up = arg2;
+ }
+ Expect.equals(new Range(low, up), -range);
+ }
+}
+
+testNegate() {
+ checkNegateRange(instruction);
+ checkNegateRange(FF, nFF);
+ checkNegateRange(nFF, FF);
+ checkNegateRange(FA, -0xFA, -0xFA);
+ checkNegateRange(length);
+ checkNegateRange(_FA_FF, -0xFF, -0xFA);
+ checkNegateRange(_0_FF, _nFF_0);
+ checkNegateRange(_nFF_FF, _nFF_FF);
+ checkNegateRange(_nFF_0, _0_FF);
+ checkNegateRange(_0_length, -lengthValue, 0);
+ checkNegateRange(_0_instruction, -instructionValue, 0);
+}
+
testAnd() {
checkAndRange(
instruction, instruction, const MinIntValue(), const MaxIntValue());
@@ -309,4 +366,5 @@
HInstruction.idCounter = 0;
testAnd();
testSub();
+ testNegate();
}
« no previous file with comments | « lib/compiler/implementation/ssa/value_range_analyzer.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698