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

Unified Diff: tests/compiler/dart2js/gvn_test.dart

Issue 17056002: Do LICM on loop header instructions. Also first instructions that throw in a loop can be LICM'ed. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 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 | « sdk/lib/_internal/compiler/implementation/ssa/optimize.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/gvn_test.dart
===================================================================
--- tests/compiler/dart2js/gvn_test.dart (revision 24019)
+++ tests/compiler/dart2js/gvn_test.dart (working copy)
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'compiler_helper.dart';
const String TEST_ONE = r"""
@@ -60,7 +61,50 @@
}
""";
+// Check that a gvn'able instruction in the loop header gets hoisted.
+const String TEST_SIX = r"""
+class A {
+ final field = 54;
+}
+
main() {
+ var a = new A();
+ while (a.field == 54) { a.field = 42; }
+}
+""";
+
+// Check that a gvn'able instruction that may throw in the loop header
+// gets hoisted.
+const String TEST_SEVEN = r"""
+class A {
+ final field;
+ A() : field = null;
+ A.bar() : field = 42;
+}
+
+main() {
+ var a = new A();
+ var b = new A.bar();
+ while (a.field == 54) { a.field = 42; b.field = 42; }
+}
+""";
+
+// Check that a check in a loop header gets hoisted.
+const String TEST_EIGHT = r"""
+class A {
+ final field;
+ A() : field = null;
+ A.bar() : field = 42;
+}
+
+main() {
+ var a = new A();
+ var b = new A.bar();
+ for (int i = 0; i < a.field; i++) { a.field = 42; b.field = 42; }
+}
+""";
+
+main() {
String generated = compile(TEST_ONE, entry: 'foo');
RegExp regexp = new RegExp(r"1 \+ [a-z]+");
checkNumberOfMatches(regexp.allMatches(generated).iterator, 1);
@@ -77,4 +121,13 @@
generated = compileAll(TEST_FIVE);
checkNumberOfMatches(
new RegExp("get\\\$foo").allMatches(generated).iterator, 1);
+
+ generated = compileAll(TEST_SIX);
+ Expect.isTrue(generated.contains('for (t1 = a.field === 54; t1;)'));
+
+ generated = compileAll(TEST_SEVEN);
+ Expect.isTrue(generated.contains('for (t1 = a.field === 54; t1;)'));
+
+ generated = compileAll(TEST_EIGHT);
+ Expect.isTrue(generated.contains('for (; i < t1; ++i)'));
}
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/ssa/optimize.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698