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 464373 425b8e0eb6d6
parent 464372 7053a0d18ad3
child 464374 bdbfe0cf3358
push id35716
push useraciure@mozilla.com
push dateSun, 17 Mar 2019 09:42:17 +0000
treeherdermozilla-central@8ee97c045359 [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);