Commit d39fc16a authored by akos.palfi@imgtec.com's avatar akos.palfi@imgtec.com

MIPS64: Fix TruncatingDiv.

- 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
parent c605a8c1
...@@ -6069,7 +6069,7 @@ void MacroAssembler::TruncatingDiv(Register result, ...@@ -6069,7 +6069,7 @@ void MacroAssembler::TruncatingDiv(Register result,
DCHECK(!result.is(at)); DCHECK(!result.is(at));
base::MagicNumbersForDivision<uint32_t> mag = base::MagicNumbersForDivision<uint32_t> mag =
base::SignedDivisionByConstant(static_cast<uint32_t>(divisor)); 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)); Mulh(result, dividend, Operand(at));
bool neg = (mag.multiplier & (static_cast<uint32_t>(1) << 31)) != 0; bool neg = (mag.multiplier & (static_cast<uint32_t>(1) << 31)) != 0;
if (divisor > 0 && neg) { if (divisor > 0 && neg) {
......
...@@ -2085,8 +2085,7 @@ void Simulator::ConfigureTypeRegister(Instruction* instr, ...@@ -2085,8 +2085,7 @@ void Simulator::ConfigureTypeRegister(Instruction* instr,
// regs. // regs.
// TODO(plind) - make the 32-bit MULT ops conform to spec regarding // TODO(plind) - make the 32-bit MULT ops conform to spec regarding
// checking of 32-bit input values, and un-define operations of HW. // checking of 32-bit input values, and un-define operations of HW.
*i64hilo = static_cast<int64_t>((int32_t)rs) * *i64hilo = rs * rt;
static_cast<int64_t>((int32_t)rt);
break; break;
case MULTU: case MULTU:
*u64hilo = static_cast<uint64_t>(rs_u) * static_cast<uint64_t>(rt_u); *u64hilo = static_cast<uint64_t>(rs_u) * static_cast<uint64_t>(rt_u);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment