From adfed0a1e7ec9cfef050ebd7b8065e719efb50e9 Mon Sep 17 00:00:00 2001 From: "plind44@gmail.com" Date: Wed, 19 Feb 2014 18:16:06 +0000 Subject: [PATCH] MIPS: Harmony: optimize Math.clz32. Port r19487 (bd8c70f) BUG=v8:2938 LOG=N R=plind44@gmail.com Review URL: https://codereview.chromium.org/172533002 Patch from Balazs Kilvady . git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@19499 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/mips/lithium-codegen-mips.cc | 7 +++++++ src/mips/lithium-mips.cc | 8 ++++++++ src/mips/lithium-mips.h | 14 ++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/src/mips/lithium-codegen-mips.cc b/src/mips/lithium-codegen-mips.cc index 762d1a7..7f9310a 100644 --- a/src/mips/lithium-codegen-mips.cc +++ b/src/mips/lithium-codegen-mips.cc @@ -3796,6 +3796,13 @@ void LCodeGen::DoMathLog(LMathLog* instr) { } +void LCodeGen::DoMathClz32(LMathClz32* instr) { + Register input = ToRegister(instr->value()); + Register result = ToRegister(instr->result()); + __ Clz(result, input); +} + + void LCodeGen::DoInvokeFunction(LInvokeFunction* instr) { ASSERT(ToRegister(instr->context()).is(cp)); ASSERT(ToRegister(instr->function()).is(a1)); diff --git a/src/mips/lithium-mips.cc b/src/mips/lithium-mips.cc index a194c29..1539deb 100644 --- a/src/mips/lithium-mips.cc +++ b/src/mips/lithium-mips.cc @@ -1101,6 +1101,7 @@ LInstruction* LChunkBuilder::DoUnaryMathOperation(HUnaryMathOperation* instr) { case kMathExp: return DoMathExp(instr); case kMathSqrt: return DoMathSqrt(instr); case kMathPowHalf: return DoMathPowHalf(instr); + case kMathClz32: return DoMathClz32(instr); default: UNREACHABLE(); return NULL; @@ -1116,6 +1117,13 @@ LInstruction* LChunkBuilder::DoMathLog(HUnaryMathOperation* instr) { } +LInstruction* LChunkBuilder::DoMathClz32(HUnaryMathOperation* instr) { + LOperand* input = UseRegisterAtStart(instr->value()); + LMathClz32* result = new(zone()) LMathClz32(input); + return DefineAsRegister(result); +} + + LInstruction* LChunkBuilder::DoMathExp(HUnaryMathOperation* instr) { ASSERT(instr->representation().IsDouble()); ASSERT(instr->value()->representation().IsDouble()); diff --git a/src/mips/lithium-mips.h b/src/mips/lithium-mips.h index 258502d..67836cf 100644 --- a/src/mips/lithium-mips.h +++ b/src/mips/lithium-mips.h @@ -125,6 +125,7 @@ class LCodeGen; V(MapEnumLength) \ V(MathAbs) \ V(MathExp) \ + V(MathClz32) \ V(MathFloor) \ V(MathFloorOfDiv) \ V(MathLog) \ @@ -802,6 +803,18 @@ class LMathLog V8_FINAL : public LTemplateInstruction<1, 1, 0> { }; +class LMathClz32 V8_FINAL : public LTemplateInstruction<1, 1, 0> { + public: + explicit LMathClz32(LOperand* value) { + inputs_[0] = value; + } + + LOperand* value() { return inputs_[0]; } + + DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32") +}; + + class LMathExp V8_FINAL : public LTemplateInstruction<1, 1, 3> { public: LMathExp(LOperand* value, @@ -2578,6 +2591,7 @@ class LChunkBuilder V8_FINAL : public LChunkBuilderBase { LInstruction* DoMathExp(HUnaryMathOperation* instr); LInstruction* DoMathSqrt(HUnaryMathOperation* instr); LInstruction* DoMathPowHalf(HUnaryMathOperation* instr); + LInstruction* DoMathClz32(HUnaryMathOperation* instr); private: enum Status { -- 2.7.4