MIPS: [turbofan] Also optimize unsigned division by constant.

Port r25061 (7fe697f)

TEST=cctest,mjsunit,unittests
BUG=
R=paul.lind@imgtec.com

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

Cr-Commit-Position: refs/heads/master@{#25081}
git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@25081 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 14e2d5d0
...@@ -188,6 +188,9 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) { ...@@ -188,6 +188,9 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
case kMipsMulHigh: case kMipsMulHigh:
__ Mulh(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); __ Mulh(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1));
break; break;
case kMipsMulHighU:
__ Mulhu(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1));
break;
case kMipsDiv: case kMipsDiv:
__ Div(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); __ Div(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1));
break; break;
......
...@@ -18,6 +18,7 @@ namespace compiler { ...@@ -18,6 +18,7 @@ namespace compiler {
V(MipsSubOvf) \ V(MipsSubOvf) \
V(MipsMul) \ V(MipsMul) \
V(MipsMulHigh) \ V(MipsMulHigh) \
V(MipsMulHighU) \
V(MipsDiv) \ V(MipsDiv) \
V(MipsDivU) \ V(MipsDivU) \
V(MipsMod) \ V(MipsMod) \
......
...@@ -307,6 +307,13 @@ void InstructionSelector::VisitInt32MulHigh(Node* node) { ...@@ -307,6 +307,13 @@ void InstructionSelector::VisitInt32MulHigh(Node* node) {
} }
void InstructionSelector::VisitUint32MulHigh(Node* node) {
MipsOperandGenerator g(this);
Emit(kMipsMulHighU, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)),
g.UseRegister(node->InputAt(1)));
}
void InstructionSelector::VisitInt32Div(Node* node) { void InstructionSelector::VisitInt32Div(Node* node) {
MipsOperandGenerator g(this); MipsOperandGenerator g(this);
Int32BinopMatcher m(node); Int32BinopMatcher m(node);
......
...@@ -740,6 +740,28 @@ void MacroAssembler::Mult(Register rs, const Operand& rt) { ...@@ -740,6 +740,28 @@ void MacroAssembler::Mult(Register rs, const Operand& rt) {
} }
void MacroAssembler::Mulhu(Register rd, Register rs, const Operand& rt) {
if (rt.is_reg()) {
if (!IsMipsArchVariant(kMips32r6)) {
multu(rs, rt.rm());
mfhi(rd);
} else {
muhu(rd, rs, rt.rm());
}
} else {
// li handles the relocation.
DCHECK(!rs.is(at));
li(at, rt);
if (!IsMipsArchVariant(kMips32r6)) {
multu(rs, at);
mfhi(rd);
} else {
muhu(rd, rs, at);
}
}
}
void MacroAssembler::Multu(Register rs, const Operand& rt) { void MacroAssembler::Multu(Register rs, const Operand& rt) {
if (rt.is_reg()) { if (rt.is_reg()) {
multu(rs, rt.rm()); multu(rs, rt.rm());
......
...@@ -593,6 +593,7 @@ class MacroAssembler: public Assembler { ...@@ -593,6 +593,7 @@ class MacroAssembler: public Assembler {
DEFINE_INSTRUCTION(Modu); DEFINE_INSTRUCTION(Modu);
DEFINE_INSTRUCTION(Mulh); DEFINE_INSTRUCTION(Mulh);
DEFINE_INSTRUCTION2(Mult); DEFINE_INSTRUCTION2(Mult);
DEFINE_INSTRUCTION(Mulhu);
DEFINE_INSTRUCTION2(Multu); DEFINE_INSTRUCTION2(Multu);
DEFINE_INSTRUCTION2(Div); DEFINE_INSTRUCTION2(Div);
DEFINE_INSTRUCTION2(Divu); DEFINE_INSTRUCTION2(Divu);
......
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