Bug 1555153 - ARM64 division by constant: compare remainder against zero. r=sstangl
authorNicolas B. Pierron <nicolas.b.pierron@nbp.name>
Sat, 01 Jun 2019 03:33:15 +0000
changeset 476619 09088ff4d2a730a8b587244f665a88d6fffa14e0
parent 476618 dc3ef720b474814d1efcece1ba386685fd4c3ddd
child 476620 ddaa898fff3d464ca8e68ef4f30608c868cc3e21
push id36104
push usercbrindusan@mozilla.com
push dateTue, 04 Jun 2019 03:45:41 +0000
treeherdermozilla-central@38c2478a4825 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssstangl
bugs1555153
milestone69.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 1555153 - ARM64 division by constant: compare remainder against zero. r=sstangl Differential Revision: https://phabricator.services.mozilla.com/D33015
js/src/jit-test/tests/ion/div-by-constant-bug1555153.js
js/src/jit/arm64/CodeGenerator-arm64.cpp
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/ion/div-by-constant-bug1555153.js
@@ -0,0 +1,5 @@
+x = [99999999999999999999999999, -(2 ** 53 - 2)];
+res = [0, 2 / 3];
+for (let i = 0; i < 2; ++i) {
+    assertEq((x[i] | 0) / 3, res[i]);
+}
--- a/js/src/jit/arm64/CodeGenerator-arm64.cpp
+++ b/js/src/jit/arm64/CodeGenerator-arm64.cpp
@@ -593,27 +593,27 @@ void CodeGenerator::visitDivConstantI(LD
   }
 
   if (!ins->mir()->isTruncated()) {
     // This is a division op. Multiply the obtained value by d to check if
     // the correct answer is an integer. This cannot overflow, since |d| > 1.
     masm.Mov(const32, d);
     masm.Msub(const32, output32, const32, lhs32);
     // bailout if (lhs - output * d != 0)
-    masm.Cmp(const32, const32);
+    masm.Cmp(const32, wzr);
     auto bailoutCond = Assembler::NonZero;
 
     // If lhs is zero and the divisor is negative, the answer should have
     // been -0.
     if (d < 0) {
       // or bailout if (lhs == 0).
       // ^                  ^
       // |                  '-- masm.Ccmp(lhs32, lhs32, .., ..)
       // '-- masm.Ccmp(.., .., vixl::ZFlag, ! bailoutCond)
-      masm.Ccmp(lhs32, lhs32, vixl::ZFlag, Assembler::Zero);
+      masm.Ccmp(lhs32, wzr, vixl::ZFlag, Assembler::Zero);
       bailoutCond = Assembler::Zero;
     }
 
     // bailout if (lhs - output * d != 0) or (d < 0 && lhs == 0)
     bailoutIf(bailoutCond, ins->snapshot());
   }
 }