Index: src/compiler/mips/code-generator-mips.cc |
diff --git a/src/compiler/mips/code-generator-mips.cc b/src/compiler/mips/code-generator-mips.cc |
index 7643b62e509b7e2aca1179be9e22ad76fee94510..74c8334184135df1f6e617140255c7b168c69fe9 100644 |
--- a/src/compiler/mips/code-generator-mips.cc |
+++ b/src/compiler/mips/code-generator-mips.cc |
@@ -54,6 +54,14 @@ class MipsOperandConverter final : public InstructionOperandConverter { |
return ToDoubleRegister(op); |
} |
+ Register InputOrZeroRegister(size_t index) { |
+ if (instr_->InputAt(index)->IsImmediate()) { |
+ DCHECK((InputInt32(index) == 0)); |
+ return zero_reg; |
+ } |
+ return InputRegister(index); |
+ } |
+ |
DoubleRegister InputOrZeroDoubleRegister(size_t index) { |
if (instr_->InputAt(index)->IsImmediate()) return kDoubleRegZero; |
@@ -381,45 +389,48 @@ FPUCondition FlagsConditionToConditionCmpFPU(bool& predicate, |
__ bind(ool->exit()); \ |
} while (0) |
- |
#define ASSEMBLE_CHECKED_STORE_FLOAT(width, asm_instr) \ |
do { \ |
Label done; \ |
if (instr->InputAt(0)->IsRegister()) { \ |
auto offset = i.InputRegister(0); \ |
- auto value = i.Input##width##Register(2); \ |
+ auto value = i.InputOrZero##width##Register(2); \ |
+ if (value.is(kDoubleRegZero) && !__ IsDoubleZeroRegSet()) { \ |
+ __ Move(kDoubleRegZero, 0.0); \ |
+ } \ |
__ Branch(USE_DELAY_SLOT, &done, hs, offset, i.InputOperand(1)); \ |
__ addu(kScratchReg, i.InputRegister(3), offset); \ |
__ asm_instr(value, MemOperand(kScratchReg, 0)); \ |
} else { \ |
auto offset = i.InputOperand(0).immediate(); \ |
- auto value = i.Input##width##Register(2); \ |
+ auto value = i.InputOrZero##width##Register(2); \ |
+ if (value.is(kDoubleRegZero) && !__ IsDoubleZeroRegSet()) { \ |
+ __ Move(kDoubleRegZero, 0.0); \ |
+ } \ |
__ Branch(&done, ls, i.InputRegister(1), Operand(offset)); \ |
__ asm_instr(value, MemOperand(i.InputRegister(3), offset)); \ |
} \ |
__ bind(&done); \ |
} while (0) |
- |
#define ASSEMBLE_CHECKED_STORE_INTEGER(asm_instr) \ |
do { \ |
Label done; \ |
if (instr->InputAt(0)->IsRegister()) { \ |
auto offset = i.InputRegister(0); \ |
- auto value = i.InputRegister(2); \ |
+ auto value = i.InputOrZeroRegister(2); \ |
__ Branch(USE_DELAY_SLOT, &done, hs, offset, i.InputOperand(1)); \ |
__ addu(kScratchReg, i.InputRegister(3), offset); \ |
__ asm_instr(value, MemOperand(kScratchReg, 0)); \ |
} else { \ |
auto offset = i.InputOperand(0).immediate(); \ |
- auto value = i.InputRegister(2); \ |
+ auto value = i.InputOrZeroRegister(2); \ |
__ Branch(&done, ls, i.InputRegister(1), Operand(offset)); \ |
__ asm_instr(value, MemOperand(i.InputRegister(3), offset)); \ |
} \ |
__ bind(&done); \ |
} while (0) |
- |
#define ASSEMBLE_ROUND_DOUBLE_TO_DOUBLE(mode) \ |
if (IsMipsArchVariant(kMips32r6)) { \ |
__ cfc1(kScratchReg, FCSR); \ |
@@ -478,11 +489,11 @@ FPUCondition FlagsConditionToConditionCmpFPU(bool& predicate, |
__ sync(); \ |
} while (0) |
-#define ASSEMBLE_ATOMIC_STORE_INTEGER(asm_instr) \ |
- do { \ |
- __ sync(); \ |
- __ asm_instr(i.InputRegister(2), i.MemoryOperand()); \ |
- __ sync(); \ |
+#define ASSEMBLE_ATOMIC_STORE_INTEGER(asm_instr) \ |
+ do { \ |
+ __ sync(); \ |
+ __ asm_instr(i.InputOrZeroRegister(2), i.MemoryOperand()); \ |
+ __ sync(); \ |
} while (0) |
#define ASSEMBLE_IEEE754_BINOP(name) \ |
@@ -1402,7 +1413,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( |
__ lb(i.OutputRegister(), i.MemoryOperand()); |
break; |
case kMipsSb: |
- __ sb(i.InputRegister(2), i.MemoryOperand()); |
+ __ sb(i.InputOrZeroRegister(2), i.MemoryOperand()); |
break; |
case kMipsLhu: |
__ lhu(i.OutputRegister(), i.MemoryOperand()); |
@@ -1417,10 +1428,10 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( |
__ Ulh(i.OutputRegister(), i.MemoryOperand()); |
break; |
case kMipsSh: |
- __ sh(i.InputRegister(2), i.MemoryOperand()); |
+ __ sh(i.InputOrZeroRegister(2), i.MemoryOperand()); |
break; |
case kMipsUsh: |
- __ Ush(i.InputRegister(2), i.MemoryOperand(), kScratchReg); |
+ __ Ush(i.InputOrZeroRegister(2), i.MemoryOperand(), kScratchReg); |
break; |
case kMipsLw: |
__ lw(i.OutputRegister(), i.MemoryOperand()); |
@@ -1429,10 +1440,10 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( |
__ Ulw(i.OutputRegister(), i.MemoryOperand()); |
break; |
case kMipsSw: |
- __ sw(i.InputRegister(2), i.MemoryOperand()); |
+ __ sw(i.InputOrZeroRegister(2), i.MemoryOperand()); |
break; |
case kMipsUsw: |
- __ Usw(i.InputRegister(2), i.MemoryOperand()); |
+ __ Usw(i.InputOrZeroRegister(2), i.MemoryOperand()); |
break; |
case kMipsLwc1: { |
__ lwc1(i.OutputSingleRegister(), i.MemoryOperand()); |
@@ -1445,13 +1456,21 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( |
case kMipsSwc1: { |
size_t index = 0; |
MemOperand operand = i.MemoryOperand(&index); |
- __ swc1(i.InputSingleRegister(index), operand); |
+ FPURegister ft = i.InputOrZeroSingleRegister(index); |
+ if (ft.is(kDoubleRegZero) && !__ IsDoubleZeroRegSet()) { |
+ __ Move(kDoubleRegZero, 0.0); |
+ } |
+ __ swc1(ft, operand); |
break; |
} |
case kMipsUswc1: { |
size_t index = 0; |
MemOperand operand = i.MemoryOperand(&index); |
- __ Uswc1(i.InputSingleRegister(index), operand, kScratchReg); |
+ FPURegister ft = i.InputOrZeroSingleRegister(index); |
+ if (ft.is(kDoubleRegZero) && !__ IsDoubleZeroRegSet()) { |
+ __ Move(kDoubleRegZero, 0.0); |
+ } |
+ __ Uswc1(ft, operand, kScratchReg); |
break; |
} |
case kMipsLdc1: |
@@ -1460,12 +1479,22 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( |
case kMipsUldc1: |
__ Uldc1(i.OutputDoubleRegister(), i.MemoryOperand(), kScratchReg); |
break; |
- case kMipsSdc1: |
- __ sdc1(i.InputDoubleRegister(2), i.MemoryOperand()); |
+ case kMipsSdc1: { |
+ FPURegister ft = i.InputOrZeroDoubleRegister(2); |
+ if (ft.is(kDoubleRegZero) && !__ IsDoubleZeroRegSet()) { |
+ __ Move(kDoubleRegZero, 0.0); |
+ } |
+ __ sdc1(ft, i.MemoryOperand()); |
break; |
- case kMipsUsdc1: |
- __ Usdc1(i.InputDoubleRegister(2), i.MemoryOperand(), kScratchReg); |
+ } |
+ case kMipsUsdc1: { |
+ FPURegister ft = i.InputOrZeroDoubleRegister(2); |
+ if (ft.is(kDoubleRegZero) && !__ IsDoubleZeroRegSet()) { |
+ __ Move(kDoubleRegZero, 0.0); |
+ } |
+ __ Usdc1(ft, i.MemoryOperand(), kScratchReg); |
break; |
+ } |
case kMipsPush: |
if (instr->InputAt(0)->IsFPRegister()) { |
__ sdc1(i.InputDoubleRegister(0), MemOperand(sp, -kDoubleSize)); |