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

Unified Diff: tests/language/modulo_test.dart

Issue 81623003: Use range information to omit checks in TRUNCDIV/MOD operations. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 | « runtime/vm/intermediate_language_x64.cc ('k') | tests/language/truncdiv_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/modulo_test.dart
===================================================================
--- tests/language/modulo_test.dart (revision 30671)
+++ tests/language/modulo_test.dart (working copy)
@@ -26,7 +26,18 @@
}
Expect.equals((i ~/ 10) + (i ~/ 10) + (i % 10), threeOp(i));
Expect.equals((i ~/ 10) + (i ~/ 12) + (i % 10) + (i % 12), fourOp(i));
+
+ // Zero test is done outside the loop.
+ if (i < 0) {
+ Expect.equals(i % -i, foo2(i));
+ Expect.equals(i ~/ -i + i % -i, fooTwo2(i));
+ } else if (i > 0) {
+ Expect.equals(i % i, foo2(i));
+ Expect.equals(i ~/ i + i % i, fooTwo2(i));
+ }
}
+ Expect.throws(() => foo2(0), (e) => e is IntegerDivisionByZeroException);
+ Expect.throws(() => fooTwo2(0), (e) => e is IntegerDivisionByZeroException);
}
foo(i) => i % 256; // This will get optimized to AND instruction.
@@ -61,4 +72,27 @@
var y0 = a % 10;
var y1 = a % 12;
return x0 + x1 + y0 + y1;
-}
+}
+
+foo2(i) {
+ // Make sure x has a range computed.
+ var x = 0;
+ if (i < 0) {
+ x = -i;
+ } else {
+ x = i;
+ }
+ return i % x;
+}
+
+
+fooTwo2(i) {
+ // Make sure x has a range computed.
+ var x = 0;
+ if (i < 0) {
+ x = -i;
+ } else {
+ x = i;
+ }
+ return i ~/ x + i % x;
+}
« no previous file with comments | « runtime/vm/intermediate_language_x64.cc ('k') | tests/language/truncdiv_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698