Bug 1534810 - ARM64: LMulI should copy registers when multiplying by 1. r=sstangl
authorNicolas B. Pierron <nicolas.b.pierron@nbp.name>
Thu, 14 Mar 2019 21:48:08 +0000
changeset 522036 425b8e0eb6d60a2b78a79f8948774d2202155122
parent 522035 7053a0d18ad3d70c9f86135db1278e04df30d1c7
child 522037 bdbfe0cf3358f6b6eb32d45af7f9f1ab6164f924
push id10871
push usercbrindusan@mozilla.com
push dateMon, 18 Mar 2019 15:49:32 +0000
treeherdermozilla-beta@018abdd16060 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssstangl
bugs1534810
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1534810 - ARM64: LMulI should copy registers when multiplying by 1. r=sstangl Differential Revision: https://phabricator.services.mozilla.com/D23553
js/src/jit-test/tests/ion/muli-constant-1-bug1534810.js
js/src/jit/arm64/CodeGenerator-arm64.cpp
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/ion/muli-constant-1-bug1534810.js
@@ -0,0 +1,15 @@
+function f() {}
+function g(x) {
+    var a = 0, b = NaN, c = 1, d = 0, e = 0;
+    a = (x >> 0);
+    b = f();
+    b = +b;
+    c = Math.round(1);
+    d = Math.imul(b, c);
+    e = e + a;
+    e = e + d;
+    return e;
+}
+for (let i = 0; i < 2; ++i) {
+    assertEq(g(), 0);
+}
--- a/js/src/jit/arm64/CodeGenerator-arm64.cpp
+++ b/js/src/jit/arm64/CodeGenerator-arm64.cpp
@@ -313,17 +313,19 @@ void CodeGenerator::visitMulI(LMulI* ins
     switch (constant) {
       case -1:
         masm.Negs(destreg32, Operand(lhsreg32));
         break;  // Go to overflow check.
       case 0:
         masm.Mov(destreg32, wzr);
         return;  // Avoid overflow check.
       case 1:
-        // nop
+        if (destreg != lhsreg) {
+          masm.Mov(destreg32, lhsreg32);
+        }
         return;  // Avoid overflow check.
       case 2:
         masm.Adds(destreg32, lhsreg32, Operand(lhsreg32));
         break;  // Go to overflow check.
       default:
         // Use shift if cannot overflow and constant is a power of 2
         if (!mul->canOverflow() && constant > 0) {
           int32_t shift = FloorLog2(constant);