MIPS: [turbofan] Also optimize unsigned division by constant.
authorbalazs.kilvady@imgtec.com <balazs.kilvady@imgtec.com>
Mon, 3 Nov 2014 16:40:54 +0000 (16:40 +0000)
committerbalazs.kilvady@imgtec.com <balazs.kilvady@imgtec.com>
Mon, 3 Nov 2014 16:41:18 +0000 (16:41 +0000)
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

src/compiler/mips/code-generator-mips.cc
src/compiler/mips/instruction-codes-mips.h
src/compiler/mips/instruction-selector-mips.cc
src/mips/macro-assembler-mips.cc
src/mips/macro-assembler-mips.h

index 9a8b98a6355409f5eb72e27cdc2aee6f4b59772c..2a079404730de74a0a71050174d2564002894a8e 100644 (file)
@@ -188,6 +188,9 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
     case kMipsMulHigh:
       __ Mulh(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1));
       break;
+    case kMipsMulHighU:
+      __ Mulhu(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1));
+      break;
     case kMipsDiv:
       __ Div(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1));
       break;
index 4c18ae1e5a07939a47db0e617cc22644d98d8173..1e8be7ff67887207be547270fa1af5905d2b209d 100644 (file)
@@ -18,6 +18,7 @@ namespace compiler {
   V(MipsSubOvf)                    \
   V(MipsMul)                       \
   V(MipsMulHigh)                   \
+  V(MipsMulHighU)                  \
   V(MipsDiv)                       \
   V(MipsDivU)                      \
   V(MipsMod)                       \
index 637d98b7849773d90d2bca1fd1be592fc6f5dac3..f5a79ec30a101a02b3fdaa9c6bc33d1321d43093 100644 (file)
@@ -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) {
   MipsOperandGenerator g(this);
   Int32BinopMatcher m(node);
index 03419cad03cb38f3a80a8e19e87371528382d911..a5af1b8d65b1450d777d346c702fb44a1f2d5292 100644 (file)
@@ -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) {
   if (rt.is_reg()) {
     multu(rs, rt.rm());
index 9ee594ef957f0f0851027a381cc2a22eb67b3c56..d500eaa8bf45f0cae032ce3ab995542a30b26523 100644 (file)
@@ -593,6 +593,7 @@ class MacroAssembler: public Assembler {
   DEFINE_INSTRUCTION(Modu);
   DEFINE_INSTRUCTION(Mulh);
   DEFINE_INSTRUCTION2(Mult);
+  DEFINE_INSTRUCTION(Mulhu);
   DEFINE_INSTRUCTION2(Multu);
   DEFINE_INSTRUCTION2(Div);
   DEFINE_INSTRUCTION2(Divu);