MIPS: Fix FlooringDivByPowerOf2I.
authorplind44@gmail.com <plind44@gmail.com@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Wed, 14 May 2014 17:34:09 +0000 (17:34 +0000)
committerplind44@gmail.com <plind44@gmail.com@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Wed, 14 May 2014 17:34:09 +0000 (17:34 +0000)
Port r21313 (3b4cb0b)

Original commit message:
Fix for divisor=1, found during code inspection. We can't hit this bug, due to
HDiv::Canonicalize() discarding the operation, but it might avoid a future bug
hunt. Patch also includes a small tidying of the ARM64 code.

BUG=
R=plind44@gmail.com

Review URL: https://codereview.chromium.org/277893003

Patch from Balazs Kilvady <kilvadyb@homejinni.com>.

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@21317 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/mips/lithium-codegen-mips.cc

index bb0b358..e09feea 100644 (file)
@@ -1298,9 +1298,14 @@ void LCodeGen::DoFlooringDivByPowerOf2I(LFlooringDivByPowerOf2I* instr) {
   Register scratch = scratch0();
   ASSERT(!scratch.is(dividend));
 
+  // If the divisor is 1, return the dividend.
+  if (divisor == 1) {
+    __ Move(result, dividend);
+    return;
+  }
+
   // If the divisor is positive, things are easy: There can be no deopts and we
   // can simply do an arithmetic right shift.
-  if (divisor == 1) return;
   uint16_t shift = WhichPowerOf2Abs(divisor);
   if (divisor > 1) {
     __ sra(result, dividend, shift);