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

Side by Side Diff: test/mjsunit/induction-variable-turbofan.js

Issue 2260153002: [turbofan] Induction variable decrement bound analysis. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@DeleteUnusedVar
Patch Set: Simplify if-else loop Created 4 years, 4 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
« no previous file with comments | « src/compiler/typer.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
(Empty)
1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Flags: --allow-natives-syntax --turbo
6
7 // TurboFan optimizes integer loops. These tests check that we compute
8 // the correct upper and lower bounds.
9 function positive_increment() {
10 for (var i = 5; i < 10; i++) {
11 if (i < 0) return false;
12 if (i > 20) return false;
13 if (i === 7) return true;
14 }
15 return false;
16 }
17
18 function positive_increment_strict() {
19 for (var i = 5; i < 10; i++) {
20 if (i < 0) return false;
21 if (i === 10) return false;
22 }
23 return true;
24 }
25
26 function positive_increment_non_strict() {
27 for (var i = 5; i <= 10; i++) {
28 if (i < 0) return false;
29 if (i === 10) return true;
30 }
31 return false;
32 }
33
34 function negative_increment() {
35 for (var i = 10; i > 5;) {
36 if (i < 0) return false;
37 if (i > 20) return false;
38 if (i === 7) return true;
39 i -= 1;
40 }
41 return false;
42 }
43
44 function positive_decrement() {
45 for (var i = 10; i > 5; i--) {
46 if (i < 0) return false;
47 if (i === 7) return true;
48 }
49 return false;
50 }
51
52 function positive_decrement_strict() {
53 for (var i = 10; i > 5; i--) {
54 if (i < 0) return false;
55 if (i === 5) return false;
56 }
57 return true;
58 }
59 function positive_decrement_non_strict() {
60 for (var i = 10; i >= 5; i--) {
61 if (i < 0) return false;
62 if (i === 5) return true;
63 }
64 return false;
65 }
66
67 function negative_decrement() {
68 for (var i = 5; i < 10;) {
69 if (i < 0) return false;
70 if (i === 7) return true;
71 i -= -1;
72 }
73 return false;
74 }
75
76 function variable_bound() {
77 for (var i = 5; i < 10; i++) {
78 for (var j = 5; j < i; j++) {
79 if (j < 0) return false;
80 if (j === 7) return true;
81 }
82 }
83 return false;
84
85 }
86
87 function test(f) {
88 f();
89 assertTrue(f());
90 %OptimizeFunctionOnNextCall(f);
91 assertTrue(f());
92 }
93
94 test(positive_increment);
95 test(positive_increment_strict);
96 test(positive_increment_non_strict);
97 test(negative_increment);
98 test(positive_decrement);
99 test(positive_decrement_strict);
100 test(positive_decrement_non_strict);
101 test(negative_decrement);
102 test(variable_bound);
OLDNEW
« no previous file with comments | « src/compiler/typer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698