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

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

Issue 14057004: Convert diamond shaped control flow into a single conditional instruction. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: address Florian's comments 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
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
5 // Test if-convertion pass in the optimizing compiler.
6
7 import "package:expect/expect.dart";
8
9 f1(i) => (i == 0) ? 0 : 1;
10 f2(i) => (i == 0) ? 2 : 3;
11 f3(i) => (i == null) ? 0 : 1;
12 f4(i) => (i == null) ? 2 : 3;
13
14 f5(i) => (i != 0) ? 0 : 1;
15 f6(i) => (i != 0) ? 2 : 3;
16 f7(i) => (i != null) ? 0 : 1;
17 f8(i) => (i != null) ? 2 : 3;
18
19 f9(i) => identical(i, 0) ? 0 : 1;
20 f10(i) => identical(i, 0) ? 2 : 3;
21 f11(i) => identical(i, null) ? 0 : 1;
22 f12(i) => identical(i, null) ? 2 : 3;
23
24 f13(i) => !identical(i, 0) ? 0 : 1;
25 f14(i) => !identical(i, 0) ? 2 : 3;
26 f15(i) => !identical(i, null) ? 0 : 1;
27 f16(i) => !identical(i, null) ? 2 : 3;
28
29 const POWER_OF_2 = 0x1000000000;
30
31 bigPower(i) => (i == 11) ? 0 : POWER_OF_2;
32
33 main() {
34 for (var i = 0; i < 10000; i++) {
35 f1(i);
36 f2(i);
37 f3(i);
38 f4(i);
39 f5(i);
40 f6(i);
41 f7(i);
42 f8(i);
43 f9(i);
44 f10(i);
45 f11(i);
46 f12(i);
47 f13(i);
48 f14(i);
49 f15(i);
50 f16(i);
51 bigPower(i);
52 }
53
54 Expect.equals(0, f1(0));
55 Expect.equals(1, f1(44));
56 Expect.equals(2, f2(0));
57 Expect.equals(3, f2(44));
58 Expect.equals(0, f3(null));
59 Expect.equals(1, f3(44));
60 Expect.equals(2, f4(null));
61 Expect.equals(3, f4(44));
62
63 Expect.equals(1, f5(0));
64 Expect.equals(0, f5(44));
65 Expect.equals(3, f6(0));
66 Expect.equals(2, f6(44));
67 Expect.equals(1, f7(null));
68 Expect.equals(0, f7(44));
69 Expect.equals(3, f8(null));
70 Expect.equals(2, f8(44));
71
72 Expect.equals(0, f9(0));
73 Expect.equals(1, f9(44));
74 Expect.equals(2, f10(0));
75 Expect.equals(3, f10(44));
76 Expect.equals(0, f11(null));
77 Expect.equals(1, f11(44));
78 Expect.equals(2, f12(null));
79 Expect.equals(3, f12(44));
80
81 Expect.equals(1, f13(0));
82 Expect.equals(0, f13(44));
83 Expect.equals(3, f14(0));
84 Expect.equals(2, f14(44));
85 Expect.equals(1, f15(null));
86 Expect.equals(0, f15(44));
87 Expect.equals(3, f16(null));
88 Expect.equals(2, f16(44));
89
90 Expect.equals(0, bigPower(11));
91 Expect.equals(POWER_OF_2, bigPower(12));
92 }
OLDNEW
« runtime/vm/flow_graph_optimizer.cc ('K') | « runtime/vm/intermediate_language_x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698