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

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

Issue 13884009: Support IfThenElse instruction pattern for arbitrary smi constants. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 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') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // Test if-convertion pass in the optimizing compiler. 5 // Test if-convertion pass in the optimizing compiler.
6 6
7 import "package:expect/expect.dart"; 7 import "package:expect/expect.dart";
8 8
9 f1(i) => (i == 0) ? 0 : 1; 9 f1(i) => (i == 0) ? 0 : 1;
10 f2(i) => (i == 0) ? 2 : 3; 10 f2(i) => (i == 0) ? 2 : 3;
11 f3(i) => (i == null) ? 0 : 1; 11 f3(i) => (i == null) ? 0 : 1;
12 f4(i) => (i == null) ? 2 : 3; 12 f4(i) => (i == null) ? 2 : 3;
13 13
14 f5(i) => (i != 0) ? 0 : 1; 14 f5(i) => (i != 0) ? 0 : 1;
15 f6(i) => (i != 0) ? 2 : 3; 15 f6(i) => (i != 0) ? 2 : 3;
16 f7(i) => (i != null) ? 0 : 1; 16 f7(i) => (i != null) ? 0 : 1;
17 f8(i) => (i != null) ? 2 : 3; 17 f8(i) => (i != null) ? 2 : 3;
18 18
19 f9(i) => identical(i, 0) ? 0 : 1; 19 f9(i) => identical(i, 0) ? 0 : 1;
20 f10(i) => identical(i, 0) ? 2 : 3; 20 f10(i) => identical(i, 0) ? 2 : 3;
21 f11(i) => identical(i, null) ? 0 : 1; 21 f11(i) => identical(i, null) ? 0 : 1;
22 f12(i) => identical(i, null) ? 2 : 3; 22 f12(i) => identical(i, null) ? 2 : 3;
23 23
24 f13(i) => !identical(i, 0) ? 0 : 1; 24 f13(i) => !identical(i, 0) ? 0 : 1;
25 f14(i) => !identical(i, 0) ? 2 : 3; 25 f14(i) => !identical(i, 0) ? 2 : 3;
26 f15(i) => !identical(i, null) ? 0 : 1; 26 f15(i) => !identical(i, null) ? 0 : 1;
27 f16(i) => !identical(i, null) ? 2 : 3; 27 f16(i) => !identical(i, null) ? 2 : 3;
Florian Schneider 2013/04/12 15:18:52 Maybe add ad test for the cases !power_of_two &&
Vyacheslav Egorov (Google) 2013/04/12 15:26:34 Done.
28 28
29 const POWER_OF_2 = 0x1000000000; 29 const POWER_OF_2 = 0x1000000000;
30 30
31 bigPower(i) => (i == 11) ? 0 : POWER_OF_2; 31 bigPower(i) => (i == 11) ? 0 : POWER_OF_2;
32 32
33 cse(i) {
34 final a = i == 0 ? 0 : 1;
35 final b = i == 0 ? 2 : 3;
36 return a + b;
37 }
38
33 main() { 39 main() {
34 for (var i = 0; i < 10000; i++) { 40 for (var i = 0; i < 10000; i++) {
35 f1(i); 41 f1(i);
36 f2(i); 42 f2(i);
37 f3(i); 43 f3(i);
38 f4(i); 44 f4(i);
39 f5(i); 45 f5(i);
40 f6(i); 46 f6(i);
41 f7(i); 47 f7(i);
42 f8(i); 48 f8(i);
43 f9(i); 49 f9(i);
44 f10(i); 50 f10(i);
45 f11(i); 51 f11(i);
46 f12(i); 52 f12(i);
47 f13(i); 53 f13(i);
48 f14(i); 54 f14(i);
49 f15(i); 55 f15(i);
50 f16(i); 56 f16(i);
57 cse(i);
51 bigPower(i); 58 bigPower(i);
52 } 59 }
53 60
54 Expect.equals(0, f1(0)); 61 Expect.equals(0, f1(0));
55 Expect.equals(1, f1(44)); 62 Expect.equals(1, f1(44));
56 Expect.equals(2, f2(0)); 63 Expect.equals(2, f2(0));
57 Expect.equals(3, f2(44)); 64 Expect.equals(3, f2(44));
58 Expect.equals(0, f3(null)); 65 Expect.equals(0, f3(null));
59 Expect.equals(1, f3(44)); 66 Expect.equals(1, f3(44));
60 Expect.equals(2, f4(null)); 67 Expect.equals(2, f4(null));
(...skipping 21 matching lines...) Expand all
82 Expect.equals(0, f13(44)); 89 Expect.equals(0, f13(44));
83 Expect.equals(3, f14(0)); 90 Expect.equals(3, f14(0));
84 Expect.equals(2, f14(44)); 91 Expect.equals(2, f14(44));
85 Expect.equals(1, f15(null)); 92 Expect.equals(1, f15(null));
86 Expect.equals(0, f15(44)); 93 Expect.equals(0, f15(44));
87 Expect.equals(3, f16(null)); 94 Expect.equals(3, f16(null));
88 Expect.equals(2, f16(44)); 95 Expect.equals(2, f16(44));
89 96
90 Expect.equals(0, bigPower(11)); 97 Expect.equals(0, bigPower(11));
91 Expect.equals(POWER_OF_2, bigPower(12)); 98 Expect.equals(POWER_OF_2, bigPower(12));
99
100 Expect.equals(2, cse(0));
101 Expect.equals(4, cse(1));
92 } 102 }
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language_x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698