From 6479ea33792abc4cf72c3566bbd66b6dedfb97dc Mon Sep 17 00:00:00 2001 From: "verwaest@chromium.org" Date: Tue, 27 Aug 2013 14:02:08 +0000 Subject: [PATCH] Eliminate Smi check when changing from Smi to Integer32 BUG= R=verwaest@chromium.org Review URL: https://chromiumcodereview.appspot.com/22824003 Patch from Weiliang Lin . git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16362 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/arm/lithium-arm.cc | 7 ++++--- src/ia32/lithium-ia32.cc | 9 +++++---- src/x64/lithium-x64.cc | 5 +++-- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/arm/lithium-arm.cc b/src/arm/lithium-arm.cc index 5bca4f50ac..5978fad604 100644 --- a/src/arm/lithium-arm.cc +++ b/src/arm/lithium-arm.cc @@ -1925,11 +1925,12 @@ LInstruction* LChunkBuilder::DoChange(HChange* instr) { ASSERT(to.IsInteger32()); LOperand* value = NULL; LInstruction* res = NULL; - if (instr->value()->type().IsSmi()) { - value = UseRegisterAtStart(instr->value()); + HValue* val = instr->value(); + if (val->type().IsSmi() || val->representation().IsSmi()) { + value = UseRegisterAtStart(val); res = DefineAsRegister(new(zone()) LSmiUntag(value, false)); } else { - value = UseRegister(instr->value()); + value = UseRegister(val); LOperand* temp1 = TempRegister(); LOperand* temp2 = FixedTemp(d11); res = DefineSameAsFirst(new(zone()) LTaggedToI(value, diff --git a/src/ia32/lithium-ia32.cc b/src/ia32/lithium-ia32.cc index b6e75414d9..7ec12582a9 100644 --- a/src/ia32/lithium-ia32.cc +++ b/src/ia32/lithium-ia32.cc @@ -1945,13 +1945,14 @@ LInstruction* LChunkBuilder::DoChange(HChange* instr) { return AssignEnvironment(DefineSameAsFirst(new(zone()) LCheckSmi(value))); } else { ASSERT(to.IsInteger32()); - if (instr->value()->type().IsSmi()) { - LOperand* value = UseRegister(instr->value()); + HValue* val = instr->value(); + if (val->type().IsSmi() || val->representation().IsSmi()) { + LOperand* value = UseRegister(val); return DefineSameAsFirst(new(zone()) LSmiUntag(value, false)); } else { bool truncating = instr->CanTruncateToInt32(); if (CpuFeatures::IsSafeForSnapshot(SSE2)) { - LOperand* value = UseRegister(instr->value()); + LOperand* value = UseRegister(val); LOperand* xmm_temp = (truncating && CpuFeatures::IsSupported(SSE3)) ? NULL @@ -1959,7 +1960,7 @@ LInstruction* LChunkBuilder::DoChange(HChange* instr) { LTaggedToI* res = new(zone()) LTaggedToI(value, xmm_temp); return AssignEnvironment(DefineSameAsFirst(res)); } else { - LOperand* value = UseFixed(instr->value(), ecx); + LOperand* value = UseFixed(val, ecx); LTaggedToINoSSE2* res = new(zone()) LTaggedToINoSSE2(value, TempRegister(), TempRegister(), TempRegister()); diff --git a/src/x64/lithium-x64.cc b/src/x64/lithium-x64.cc index a39810950d..57938b213f 100644 --- a/src/x64/lithium-x64.cc +++ b/src/x64/lithium-x64.cc @@ -1843,8 +1843,9 @@ LInstruction* LChunkBuilder::DoChange(HChange* instr) { return AssignEnvironment(DefineSameAsFirst(new(zone()) LCheckSmi(value))); } else { ASSERT(to.IsInteger32()); - LOperand* value = UseRegister(instr->value()); - if (instr->value()->type().IsSmi()) { + HValue* val = instr->value(); + LOperand* value = UseRegister(val); + if (val->type().IsSmi() || val->representation().IsSmi()) { return DefineSameAsFirst(new(zone()) LSmiUntag(value, false)); } else { bool truncating = instr->CanTruncateToInt32();