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

Side by Side Diff: tests/language/div_with_power_of_two_test.dart

Issue 12091100: Use SAR for positive divident by a power-of two constant divisor. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/intermediate_language_x64.cc ('k') | tests/language/language_dart2js.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4 // Test division by power of two.
5 // Test that results before and after optimization are the same.
6
7 // [function, [list of tuples argument/result]].
8 var expectedResults =
9 [ [divBy1,
10 [[134217730, 134217730],
11 [-134217730, -134217730],
12 [10, 10],
13 [-10, -10]]],
14 [divByNeg1,
15 [[134217730, -134217730],
16 [-134217730, 134217730],
17 [10, -10],
18 [-10, 10]]],
19 [divBy2,
20 [[134217730, 67108865],
21 [-134217730, -67108865],
22 [10, 5],
23 [-10, -5]]],
24 [divByNeg2,
25 [[134217730, -67108865],
26 [-134217730, 67108865],
27 [10, -5],
28 [-10, 5]]],
29 [divBy4,
30 [[134217730, 33554432],
31 [-134217730, -33554432],
32 [10, 2],
33 [-10, -2]]],
34 [divByNeg4,
35 [[134217730, -33554432],
36 [-134217730, 33554432],
37 [10, -2],
38 [-10, 2]]],
39 [divBy134217728,
40 [[134217730, 1],
41 [-134217730, -1],
42 [10, 0],
43 [-10, 0]]],
44 [divByNeg134217728,
45 [[134217730, -1],
46 [-134217730, 1],
47 [10, 0],
48 [-10, 0]]],
49 // Use different functions for 64 bit arguments.
50 [divBy4_,
51 [[549755813990, 137438953497],
52 [-549755813990, -137438953497],
53 [288230925907525632, 72057731476881408],
54 [-288230925907525632, -72057731476881408]]],
55 [divByNeg4_,
56 [[549755813990, -137438953497],
57 [-549755813990, 137438953497],
58 [288230925907525632, -72057731476881408],
59 [-288230925907525632, 72057731476881408]]],
60 [divBy549755813888,
61 [[549755813990, 1],
62 [-549755813990, -1],
63 [288230925907525632, 524289],
64 [-288230925907525632, -524289]]],
65 [divByNeg549755813888,
66 [[549755813990, -1],
67 [-549755813990, 1],
68 [288230925907525632, -524289],
69 [-288230925907525632, 524289]]],
70 ];
71
72 divBy0(a) => a ~/ 0;
73 divBy1(a) => a ~/ 1;
74 divByNeg1(a) => a ~/ -1;
75 divBy2(a) => a ~/ 2;
76 divByNeg2(a) => a ~/ -2;
77 divBy4(a) => a ~/ 4;
78 divByNeg4(a) => a ~/ -4;
79 divBy134217728(a) => a ~/ 134217728;
80 divByNeg134217728(a) => a ~/ -134217728;
81
82 divBy4_(a) => a ~/ 4;
83 divByNeg4_(a) => a ~/ -4;
84 divBy549755813888(a) => a ~/ 549755813888;
85 divByNeg549755813888(a) => a ~/ -549755813888;
86
87 main() {
88 for (int i = 0; i < 8000; i++) {
89 for (var e in expectedResults) {
90 Function f = e[0];
91 List values = e[1];
92 for (var v in values) {
93 int arg = v[0];
94 int res = v[1];
95 Expect.equals(res, f(arg));
96 }
97 }
98 try {
99 divBy0(4);
100 Expect.fail("Should have thrown exception.");
101 } on IntegerDivisionByZeroException catch (e) {}
102 }
103 }
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language_x64.cc ('k') | tests/language/language_dart2js.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698