From 5a0d1ba8311855cff30e4c6b270887686383296e Mon Sep 17 00:00:00 2001 From: "olivf@chromium.org" Date: Thu, 12 Sep 2013 16:14:38 +0000 Subject: [PATCH] NumberUntagD is faster when untagging in a temp register BUG= R=ulan@chromium.org Review URL: https://codereview.chromium.org/23684056 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16690 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/ia32/lithium-codegen-ia32.cc | 23 +++++++++++++---------- src/ia32/lithium-ia32.cc | 4 +--- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/ia32/lithium-codegen-ia32.cc b/src/ia32/lithium-codegen-ia32.cc index 2df7a95..d50b780 100644 --- a/src/ia32/lithium-codegen-ia32.cc +++ b/src/ia32/lithium-codegen-ia32.cc @@ -5289,11 +5289,13 @@ void LCodeGen::EmitNumberUntagDNoSSE2(Register input_reg, } __ bind(&load_smi); - __ SmiUntag(input_reg); // Untag smi before converting to float. - __ push(input_reg); + // Clobbering a temp is faster than re-tagging the + // input register since we avoid dependencies. + __ mov(temp_reg, input_reg); + __ SmiUntag(temp_reg); // Untag smi before converting to float. + __ push(temp_reg); __ fild_s(Operand(esp, 0)); - __ pop(input_reg); - __ SmiTag(input_reg); // Retag smi. + __ add(esp, Immediate(kPointerSize)); __ bind(&done); X87CommitWrite(res_reg); } @@ -5349,11 +5351,12 @@ void LCodeGen::EmitNumberUntagD(Register input_reg, ASSERT(mode == NUMBER_CANDIDATE_IS_SMI); } - // Smi to XMM conversion __ bind(&load_smi); - __ SmiUntag(input_reg); // Untag smi before converting to float. - __ cvtsi2sd(result_reg, Operand(input_reg)); - __ SmiTag(input_reg); // Retag smi. + // Smi to XMM conversion. Clobbering a temp is faster than re-tagging the + // input register since we avoid dependencies. + __ mov(temp_reg, input_reg); + __ SmiUntag(temp_reg); // Untag smi before converting to float. + __ cvtsi2sd(result_reg, Operand(temp_reg)); __ bind(&done); } @@ -5427,14 +5430,14 @@ void LCodeGen::DoNumberUntagD(LNumberUntagD* instr) { LOperand* input = instr->value(); ASSERT(input->IsRegister()); LOperand* temp = instr->temp(); - ASSERT(temp == NULL || temp->IsRegister()); + ASSERT(temp->IsRegister()); LOperand* result = instr->result(); ASSERT(result->IsDoubleRegister()); Register input_reg = ToRegister(input); bool deoptimize_on_minus_zero = instr->hydrogen()->deoptimize_on_minus_zero(); - Register temp_reg = deoptimize_on_minus_zero ? ToRegister(temp) : no_reg; + Register temp_reg = ToRegister(temp); HValue* value = instr->hydrogen()->value(); NumberUntagDMode mode = value->representation().IsSmi() diff --git a/src/ia32/lithium-ia32.cc b/src/ia32/lithium-ia32.cc index 4c83f85..ca1e60d 100644 --- a/src/ia32/lithium-ia32.cc +++ b/src/ia32/lithium-ia32.cc @@ -1947,9 +1947,7 @@ LInstruction* LChunkBuilder::DoChange(HChange* instr) { info()->MarkAsDeferredCalling(); LOperand* value = UseRegister(instr->value()); // Temp register only necessary for minus zero check. - LOperand* temp = instr->deoptimize_on_minus_zero() - ? TempRegister() - : NULL; + LOperand* temp = TempRegister(); LNumberUntagD* res = new(zone()) LNumberUntagD(value, temp); return AssignEnvironment(DefineAsRegister(res)); } else if (to.IsSmi()) { -- 2.7.4