Reviewers: Yang,

Description:
Fix load elimination: can only .Equals() GVN-able instructions.

BUG=

Please review this at https://codereview.chromium.org/95193002/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+36, -28 lines):
  M src/hydrogen-load-elimination.cc
  A + test/mjsunit/compiler/load-elimination-params.js


Index: src/hydrogen-load-elimination.cc
diff --git a/src/hydrogen-load-elimination.cc b/src/hydrogen-load-elimination.cc index f37de90ff3d37311d0d3d4fa6916967bed036b87..f3b574847f8e3ed6b9e5807fa0cee894b18af41b 100644
--- a/src/hydrogen-load-elimination.cc
+++ b/src/hydrogen-load-elimination.cc
@@ -349,7 +349,9 @@ class HLoadEliminationTable : public ZoneObject {

   bool Equal(HValue* a, HValue* b) {
     if (a == b) return true;
-    if (a != NULL && b != NULL) return a->Equals(b);
+    if (a != NULL && b != NULL && a->CheckFlag(HValue::kUseGVN)) {
+      return a->Equals(b);
+    }
     return false;
   }

Index: test/mjsunit/compiler/load-elimination-params.js
diff --git a/test/mjsunit/compiler/load-elimination-osr.js b/test/mjsunit/compiler/load-elimination-params.js
similarity index 67%
copy from test/mjsunit/compiler/load-elimination-osr.js
copy to test/mjsunit/compiler/load-elimination-params.js
index a57fe173ee7be04313ca7ea2c18229e23fa16375..13a4a8596d6061226b631816ca2e9fff461a015a 100644
--- a/test/mjsunit/compiler/load-elimination-osr.js
+++ b/test/mjsunit/compiler/load-elimination-params.js
@@ -27,39 +27,45 @@

 // Flags: --allow-natives-syntax --load-elimination

-// Test global load elimination in the presence of OSR compilation.
+// Test local load elimination of redundant loads and stores.

-function It(x, y) { }
-
-function foo_osr(x, limit) {
-  var o = new It();
-  o.x = x;
-  o.y = x;
-  for (var i = 0; i < limit; i++) {
-    o.y += o.x;  // Load of x cannot be hoisted due to OSR.
-  }
+function B(x, y) {
+  this.x = x;
+  this.y = y;
+  return this;
+}

-  return o.y;
+function test_params1(a, b) {
+  var i = a.x;
+  var j = a.x;
+  var k = b.x;
+  var l = b.x;
+  return i + j + k + l;
 }

-assertEquals(22, foo_osr(11, 1));
-assertEquals(24, foo_osr(12, 1));
-assertEquals(1300013, foo_osr(13, 100000));
+assertEquals(14, test_params1(new B(3, 4), new B(4, 5)));
+assertEquals(110, test_params1(new B(11, 7), new B(44, 8)));

+%OptimizeFunctionOnNextCall(test_params1);

-function foo_hot(x, limit) {
-  var o = new It();
-  o.x = x;
-  o.y = x;
-  for (var i = 0; i < limit; i++) {
-    o.y += o.x;  // Load of x can be hoisted without OSR.
-  }
+assertEquals(6, test_params1(new B(1, 7), new B(2, 8)));

-  return o.y;
+function test_params2(a, b) {
+  var o = new B(a + 1, b);
+  o.x = a;
+  var i = o.x;
+  o.x = a;
+  var j = o.x;
+  o.x = b;
+  var k = o.x;
+  o.x = b;
+  var l = o.x;
+  return i + j + k + l;
 }

-assertEquals(22, foo_hot(11, 1));
-assertEquals(24, foo_hot(12, 1));
-%OptimizeFunctionOnNextCall(foo_hot);
-assertEquals(32, foo_hot(16, 1));
-assertEquals(1300013, foo_hot(13, 100000));
+assertEquals(14, test_params2(3, 4));
+assertEquals(110, test_params2(11, 44));
+
+%OptimizeFunctionOnNextCall(test_params2);
+
+assertEquals(6, test_params2(1, 2));


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to