Commit a961d6c0 authored by bmeurer's avatar bmeurer Committed by Commit bot

[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}
parent d903c5c0
...@@ -38,7 +38,12 @@ class X64OperandConverter : public InstructionOperandConverter { ...@@ -38,7 +38,12 @@ class X64OperandConverter : public InstructionOperandConverter {
Operand OutputOperand() { return ToOperand(instr_->Output()); } Operand OutputOperand() { return ToOperand(instr_->Output()); }
Immediate ToImmediate(InstructionOperand* operand) { Immediate ToImmediate(InstructionOperand* operand) {
return Immediate(ToConstant(operand).ToInt32()); Constant constant = ToConstant(operand);
if (constant.type() == Constant::kFloat64) {
DCHECK_EQ(0, bit_cast<int64_t>(constant.ToFloat64()));
return Immediate(0);
}
return Immediate(constant.ToInt32());
} }
Operand ToOperand(InstructionOperand* op, int extra = 0) { Operand ToOperand(InstructionOperand* op, int extra = 0) {
......
...@@ -27,6 +27,10 @@ class X64OperandGenerator final : public OperandGenerator { ...@@ -27,6 +27,10 @@ class X64OperandGenerator final : public OperandGenerator {
const int64_t value = OpParameter<int64_t>(node); const int64_t value = OpParameter<int64_t>(node);
return value == static_cast<int64_t>(static_cast<int32_t>(value)); return value == static_cast<int64_t>(static_cast<int32_t>(value));
} }
case IrOpcode::kNumberConstant: {
const double value = OpParameter<double>(node);
return bit_cast<int64_t>(value) == 0;
}
default: default:
return false; return false;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment