Index: src/compiler/mips64/code-generator-mips64.cc |
diff --git a/src/compiler/mips64/code-generator-mips64.cc b/src/compiler/mips64/code-generator-mips64.cc |
index 7ccf0a774c5e5d548534fbddf4cca54c5ce4b6c4..e8fe3a398ab9432a1b62270e076366928fe36f3a 100644 |
--- a/src/compiler/mips64/code-generator-mips64.cc |
+++ b/src/compiler/mips64/code-generator-mips64.cc |
@@ -53,6 +53,18 @@ class MipsOperandConverter final : public InstructionOperandConverter { |
return ToDoubleRegister(op); |
} |
+ DoubleRegister InputOrZeroDoubleRegister(size_t index) { |
+ if (instr_->InputAt(index)->IsImmediate()) return kDoubleRegZero; |
+ |
+ return InputDoubleRegister(index); |
+ } |
+ |
+ DoubleRegister InputOrZeroSingleRegister(size_t index) { |
+ if (instr_->InputAt(index)->IsImmediate()) return kDoubleRegZero; |
+ |
+ return InputSingleRegister(index); |
+ } |
+ |
Operand InputImmediate(size_t index) { |
Constant constant = ToConstant(instr_->InputAt(index)); |
switch (constant.type()) { |
@@ -1005,14 +1017,24 @@ void CodeGenerator::AssembleArchBranch(Instruction* instr, BranchInfo* branch) { |
if (!convertCondition(branch->condition, cc)) { |
UNSUPPORTED_COND(kMips64CmpS, branch->condition); |
} |
- __ BranchF32(tlabel, NULL, cc, i.InputSingleRegister(0), |
- i.InputSingleRegister(1)); |
+ FPURegister left = i.InputOrZeroSingleRegister(0); |
+ FPURegister right = i.InputOrZeroSingleRegister(1); |
+ if ((left.is(kDoubleRegZero) || right.is(kDoubleRegZero)) && |
+ !__ IsDoubleZeroRegSet()) { |
+ __ Move(kDoubleRegZero, 0.0); |
+ } |
+ __ BranchF32(tlabel, NULL, cc, left, right); |
} else if (instr->arch_opcode() == kMips64CmpD) { |
if (!convertCondition(branch->condition, cc)) { |
UNSUPPORTED_COND(kMips64CmpD, branch->condition); |
} |
- __ BranchF64(tlabel, NULL, cc, i.InputDoubleRegister(0), |
- i.InputDoubleRegister(1)); |
+ FPURegister left = i.InputOrZeroDoubleRegister(0); |
+ FPURegister right = i.InputOrZeroDoubleRegister(1); |
+ if ((left.is(kDoubleRegZero) || right.is(kDoubleRegZero)) && |
+ !__ IsDoubleZeroRegSet()) { |
+ __ Move(kDoubleRegZero, 0.0); |
+ } |
+ __ BranchF64(tlabel, NULL, cc, left, right); |
} else { |
PrintF("AssembleArchBranch Unimplemented arch_opcode: %d\n", |
instr->arch_opcode()); |
@@ -1125,8 +1147,12 @@ void CodeGenerator::AssembleArchBoolean(Instruction* instr, |
return; |
} else if (instr->arch_opcode() == kMips64CmpD || |
instr->arch_opcode() == kMips64CmpS) { |
- FPURegister left = i.InputDoubleRegister(0); |
- FPURegister right = i.InputDoubleRegister(1); |
+ FPURegister left = i.InputOrZeroDoubleRegister(0); |
+ FPURegister right = i.InputOrZeroDoubleRegister(1); |
+ if ((left.is(kDoubleRegZero) || right.is(kDoubleRegZero)) && |
+ !__ IsDoubleZeroRegSet()) { |
+ __ Move(kDoubleRegZero, 0.0); |
+ } |
bool predicate; |
FPUCondition cc = FlagsConditionToConditionCmpFPU(predicate, condition); |
if (kArchVariant != kMips64r6) { |