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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/typer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/induction-variable-turbofan.js
diff --git a/test/mjsunit/induction-variable-turbofan.js b/test/mjsunit/induction-variable-turbofan.js
new file mode 100644
index 0000000000000000000000000000000000000000..6957859f9ee475e1609d38b3c8eaecf40eeb666f
--- /dev/null
+++ b/test/mjsunit/induction-variable-turbofan.js
@@ -0,0 +1,102 @@
+// Copyright 2016 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --allow-natives-syntax --turbo
+
+// TurboFan optimizes integer loops. These tests check that we compute
+// the correct upper and lower bounds.
+function positive_increment() {
+ for (var i = 5; i < 10; i++) {
+ if (i < 0) return false;
+ if (i > 20) return false;
+ if (i === 7) return true;
+ }
+ return false;
+}
+
+function positive_increment_strict() {
+ for (var i = 5; i < 10; i++) {
+ if (i < 0) return false;
+ if (i === 10) return false;
+ }
+ return true;
+}
+
+function positive_increment_non_strict() {
+ for (var i = 5; i <= 10; i++) {
+ if (i < 0) return false;
+ if (i === 10) return true;
+ }
+ return false;
+}
+
+function negative_increment() {
+ for (var i = 10; i > 5;) {
+ if (i < 0) return false;
+ if (i > 20) return false;
+ if (i === 7) return true;
+ i -= 1;
+ }
+ return false;
+}
+
+function positive_decrement() {
+ for (var i = 10; i > 5; i--) {
+ if (i < 0) return false;
+ if (i === 7) return true;
+ }
+ return false;
+}
+
+function positive_decrement_strict() {
+ for (var i = 10; i > 5; i--) {
+ if (i < 0) return false;
+ if (i === 5) return false;
+ }
+ return true;
+}
+function positive_decrement_non_strict() {
+ for (var i = 10; i >= 5; i--) {
+ if (i < 0) return false;
+ if (i === 5) return true;
+ }
+ return false;
+}
+
+function negative_decrement() {
+ for (var i = 5; i < 10;) {
+ if (i < 0) return false;
+ if (i === 7) return true;
+ i -= -1;
+ }
+ return false;
+}
+
+function variable_bound() {
+ for (var i = 5; i < 10; i++) {
+ for (var j = 5; j < i; j++) {
+ if (j < 0) return false;
+ if (j === 7) return true;
+ }
+ }
+ return false;
+
+}
+
+function test(f) {
+ f();
+ assertTrue(f());
+ %OptimizeFunctionOnNextCall(f);
+ assertTrue(f());
+}
+
+test(positive_increment);
+test(positive_increment_strict);
+test(positive_increment_non_strict);
+test(negative_increment);
+test(positive_decrement);
+test(positive_decrement_strict);
+test(positive_decrement_non_strict);
+test(negative_decrement);
+test(variable_bound);
« 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