From a961d6c0146e3ee4bb8a4baa50ca475b56239bc5 Mon Sep 17 00:00:00 2001 From: bmeurer Date: Wed, 3 Jun 2015 04:23:06 -0700 Subject: [PATCH] [x64] Smi zero can be used as an immediate. R=jarin@chromium.org Review URL: https://codereview.chromium.org/1150853009 Cr-Commit-Position: refs/heads/master@{#28786} --- src/compiler/x64/code-generator-x64.cc | 7 ++++++- src/compiler/x64/instruction-selector-x64.cc | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/compiler/x64/code-generator-x64.cc b/src/compiler/x64/code-generator-x64.cc index 2105d66e4..b4d200b39 100644 --- a/src/compiler/x64/code-generator-x64.cc +++ b/src/compiler/x64/code-generator-x64.cc @@ -38,7 +38,12 @@ class X64OperandConverter : public InstructionOperandConverter { Operand OutputOperand() { return ToOperand(instr_->Output()); } Immediate ToImmediate(InstructionOperand* operand) { - return Immediate(ToConstant(operand).ToInt32()); + Constant constant = ToConstant(operand); + if (constant.type() == Constant::kFloat64) { + DCHECK_EQ(0, bit_cast(constant.ToFloat64())); + return Immediate(0); + } + return Immediate(constant.ToInt32()); } Operand ToOperand(InstructionOperand* op, int extra = 0) { diff --git a/src/compiler/x64/instruction-selector-x64.cc b/src/compiler/x64/instruction-selector-x64.cc index df0f8809a..c841acebc 100644 --- a/src/compiler/x64/instruction-selector-x64.cc +++ b/src/compiler/x64/instruction-selector-x64.cc @@ -27,6 +27,10 @@ class X64OperandGenerator final : public OperandGenerator { const int64_t value = OpParameter(node); return value == static_cast(static_cast(value)); } + case IrOpcode::kNumberConstant: { + const double value = OpParameter(node); + return bit_cast(value) == 0; + } default: return false; } -- 2.34.1