Reviewers: Benedikt Meurer,

Message:
PTAL

Description:
ARM64: do not optimize away shift if its result is used as both left and right
arguments.

BUG=chromium:491049
LOG=NO
TEST=mjsunit/regress/regress-491049.js

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

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+10, -6 lines):
  M src/arm64/lithium-arm64.cc
  A + test/mjsunit/regress/regress-491049.js


Index: src/arm64/lithium-arm64.cc
diff --git a/src/arm64/lithium-arm64.cc b/src/arm64/lithium-arm64.cc
index 91b4430566060e90a1241a0ba25c366dbe510cb9..a9d661d35d2f5a3eb7162c38fd12231136a90ef1 100644
--- a/src/arm64/lithium-arm64.cc
+++ b/src/arm64/lithium-arm64.cc
@@ -2126,6 +2126,11 @@ HBitwiseBinaryOperation* LChunkBuilder::CanTransformToShiftedOp(HValue* val,
   DCHECK(hleft->representation().Equals(hinstr->representation()));
   DCHECK(hright->representation().Equals(hinstr->representation()));

+  if (hleft == hright) {
+    // Cannot replace two operands at once.
+    return NULL;
+  }
+
   if ((hright->IsConstant() &&
LikelyFitsImmField(hinstr, HConstant::cast(hright)->Integer32Value())) ||
       (hinstr->IsCommutative() && hleft->IsConstant() &&
Index: test/mjsunit/regress/regress-491049.js
diff --git a/test/mjsunit/regress/regress-filter-contexts.js b/test/mjsunit/regress/regress-491049.js
similarity index 66%
copy from test/mjsunit/regress/regress-filter-contexts.js
copy to test/mjsunit/regress/regress-491049.js
index d2abe0032548428324afd6675a7031bf53a5e56e..c010b0911dcd5f700406a5950d05e16055979857 100644
--- a/test/mjsunit/regress/regress-filter-contexts.js
+++ b/test/mjsunit/regress/regress-491049.js
@@ -2,13 +2,12 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.

-// Flags: --allow-natives-syntax
+function f(a) {
+  return (a >>> 12) + (a >>> 2);
+}

-function f() { return f.x; }
-f.__proto__ = null;
-f.prototype = "";
-
-f();
 f();
+
 %OptimizeFunctionOnNextCall(f);
+
 f();


--
--
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/d/optout.

Reply via email to