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

Unified Diff: tests/language/load_to_load_forwarding_vm_test.dart

Issue 17101028: Refactor load forwarding pass to use a Place abstraction. (Closed) Base URL: https://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 | « runtime/vm/intermediate_language.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/load_to_load_forwarding_vm_test.dart
diff --git a/tests/language/load_to_load_forwarding_vm_test.dart b/tests/language/load_to_load_forwarding_vm_test.dart
index b77854fc92a5a7042c8705775ac52a42dbac1388..02b06a02ccd9d0214d189e4a1ede76915b6c8891 100644
--- a/tests/language/load_to_load_forwarding_vm_test.dart
+++ b/tests/language/load_to_load_forwarding_vm_test.dart
@@ -51,7 +51,6 @@ testImmutableVMFields(arr, immutable) {
return arr.length;
}
-
testPhiRepresentation(f, arr) {
if (f) {
arr[0] = arr[0] + arr[1];
@@ -61,7 +60,6 @@ testPhiRepresentation(f, arr) {
return arr[0];
}
-
testPhiConvertions(f, arr) {
if (f) {
arr[0] = arr[1];
@@ -71,6 +69,112 @@ testPhiConvertions(f, arr) {
return arr[0];
}
+class X {
+ var next;
+ X(this.next);
+}
+
+testPhiForwarding(obj) {
+ if (obj.next == null) {
+ return 1;
+ }
+
+ var len = 0;
+ while (obj != null) {
+ len++;
+ obj = obj.next; // This load should not be forwarded.
+ }
+
+ return len;
+}
+
+testPhiForwarding2(obj) {
+ if (obj.next == null) {
+ return 1;
+ }
+
+ var len = 0, next = null;
+ while ((obj != null) && len < 2) {
+ len++;
+ obj = obj.next; // This load should be forwarded.
+ next = obj.next;
+ }
+
+ return len;
+}
+
+class V {
+ final f;
+ V(this.f);
+}
+
+testPhiForwarding3() {
+ var a = new V(-0.1);
+ var c = new V(0.0);
+ var b = new V(0.1);
+
+ for (var i = 0; i < 3; i++) {
+ var af = a.f;
+ var bf = b.f;
+ var cf = c.f;
+ a = new V(cf);
+ b = new V(af);
+ c = new V(bf);
+ }
+
+ Expect.equals(-0.1, a.f);
+ Expect.equals(0.1, b.f);
+ Expect.equals(0.0, c.f);
+}
+
+testPhiForwarding4() {
+ var a = new V(-0.1);
+ var b = new V(0.1);
+ var c = new V(0.0);
+
+ var result = new List(9);
+ for (var i = 0, j = 0; i < 3; i++) {
+ result[j++] = a.f;
+ result[j++] = b.f;
+ result[j++] = c.f;
+ var xa = a;
+ var xb = b;
+ a = c;
+ b = xa;
+ c = xb;
+ }
+
+ Expect.listEquals([-0.1, 0.1, 0.0,
+ 0.0, -0.1, 0.1,
+ 0.1, 0.0, -0.1], result);
+}
+
+class U {
+ var x, y;
+ U() : x = 0, y = 0;
+}
+
+testEqualPhisElimination() {
+ var u = new U();
+ var v = new U();
+ var sum = 0;
+ for (var i = 0; i < 3; i++) {
+ u.x = i;
+ u.y = i;
+ if ((i & 1) == 1) {
+ v.x = i + 1;
+ v.y = i + 1;
+ } else {
+ v.x = i - 1;
+ v.y = i - 1;
+ }
+ sum += v.x + v.y;
+ }
+ Expect.equals(4, sum);
+ Expect.equals(2, u.x);
+ Expect.equals(2, u.y);
+}
+
main() {
final fixed = new List(10);
final growable = [];
@@ -82,12 +186,19 @@ main() {
testPhiRepresentation(true, f64List);
testPhiRepresentation(false, f64List);
+ final obj = new X(new X(new X(null)));
+
for (var i = 0; i < 2000; i++) {
Expect.listEquals([0x02010000, 0x03020100], foo(new A(0, 0)));
Expect.listEquals([0x02010000, 0x03020100], bar(new A(0, 0), false));
Expect.listEquals([0x04020000, 0x03020100], bar(new A(0, 0), true));
testImmutableVMFields(fixed, true);
testPhiRepresentation(true, f64List);
+ testPhiForwarding(obj);
+ testPhiForwarding2(obj);
+ testPhiForwarding3();
+ testPhiForwarding4();
+ testEqualPhisElimination();
}
Expect.equals(1, testImmutableVMFields([], false));
@@ -99,7 +210,7 @@ main() {
u32List[0] = 0;
u32List[1] = 0x3FFFFFFF;
u32List[2] = 0x7FFFFFFF;
-
+
for (var i = 0; i < 4000; i++) {
testPhiConvertions(true, u32List);
testPhiConvertions(false, u32List);
« no previous file with comments | « runtime/vm/intermediate_language.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698