MIPS64: Fix TruncatingDiv.
authorakos.palfi@imgtec.com <akos.palfi@imgtec.com>
Wed, 8 Oct 2014 16:15:28 +0000 (16:15 +0000)
committerakos.palfi@imgtec.com <akos.palfi@imgtec.com>
Wed, 8 Oct 2014 16:15:28 +0000 (16:15 +0000)
- Fix the Macroassembler::TruncatingDiv to compute
  the correct result even when the magic number is negative.
- Fix the MULT instruction in the simulator.

TEST=mjsunit/compiler/division-by-constant
BUG=
R=dusan.milosavljevic@imgtec.com

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

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

src/mips64/macro-assembler-mips64.cc
src/mips64/simulator-mips64.cc

index 9aa7570..2d3241f 100644 (file)
@@ -6069,7 +6069,7 @@ void MacroAssembler::TruncatingDiv(Register result,
   DCHECK(!result.is(at));
   base::MagicNumbersForDivision<uint32_t> mag =
   base::SignedDivisionByConstant(static_cast<uint32_t>(divisor));
-  li(at, Operand(mag.multiplier));
+  li(at, Operand(static_cast<int32_t>(mag.multiplier)));
   Mulh(result, dividend, Operand(at));
   bool neg = (mag.multiplier & (static_cast<uint32_t>(1) << 31)) != 0;
   if (divisor > 0 && neg) {
index 4c74939..0039665 100644 (file)
@@ -2085,8 +2085,7 @@ void Simulator::ConfigureTypeRegister(Instruction* instr,
           // regs.
           // TODO(plind) - make the 32-bit MULT ops conform to spec regarding
           //   checking of 32-bit input values, and un-define operations of HW.
-          *i64hilo = static_cast<int64_t>((int32_t)rs) *
-              static_cast<int64_t>((int32_t)rt);
+          *i64hilo = rs * rt;
           break;
         case MULTU:
           *u64hilo = static_cast<uint64_t>(rs_u) * static_cast<uint64_t>(rt_u);