Index: test/unittests/compiler/mips64/instruction-selector-mips64-unittest.cc |
diff --git a/test/unittests/compiler/mips64/instruction-selector-mips64-unittest.cc b/test/unittests/compiler/mips64/instruction-selector-mips64-unittest.cc |
index c82cb9fe4f386854aa7bc06ac08781587d923211..6f640283680857d901bdba29e2ae62019123a0b7 100644 |
--- a/test/unittests/compiler/mips64/instruction-selector-mips64-unittest.cc |
+++ b/test/unittests/compiler/mips64/instruction-selector-mips64-unittest.cc |
@@ -1491,6 +1491,203 @@ TEST_F(InstructionSelectorTest, Float64Abs) { |
EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
} |
+TEST_F(InstructionSelectorTest, Float32AddWithFloat32Mul) { |
+ { |
+ StreamBuilder m(this, MachineType::Float32(), MachineType::Float32(), |
+ MachineType::Float32(), MachineType::Float32()); |
+ Node* const p0 = m.Parameter(0); |
+ Node* const p1 = m.Parameter(1); |
+ Node* const p2 = m.Parameter(2); |
+ Node* const n = m.Float32Add(m.Float32Mul(p0, p1), p2); |
+ m.Return(n); |
+ Stream s = m.Build(); |
+ ASSERT_EQ(1U, s.size()); |
+ if (kArchVariant == kMips64r2) { |
+ EXPECT_EQ(kMips64MaddS, s[0]->arch_opcode()); |
+ } else if (kArchVariant == kMips64r6) { |
+ EXPECT_EQ(kMips64MaddfS, s[0]->arch_opcode()); |
+ } |
+ ASSERT_EQ(3U, s[0]->InputCount()); |
+ EXPECT_EQ(s.ToVreg(p2), s.ToVreg(s[0]->InputAt(0))); |
+ EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(1))); |
+ EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(2))); |
+ ASSERT_EQ(1U, s[0]->OutputCount()); |
+ if (kArchVariant == kMips64r2) { |
+ EXPECT_FALSE( |
+ UnallocatedOperand::cast(s[0]->Output())->HasSameAsInputPolicy()); |
+ } else if (kArchVariant == kMips64r6) { |
+ EXPECT_TRUE( |
+ UnallocatedOperand::cast(s[0]->Output())->HasSameAsInputPolicy()); |
+ } |
+ EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
+ EXPECT_EQ(kFlags_none, s[0]->flags_mode()); |
+ } |
+ { |
+ StreamBuilder m(this, MachineType::Float32(), MachineType::Float32(), |
+ MachineType::Float32(), MachineType::Float32()); |
+ Node* const p0 = m.Parameter(0); |
+ Node* const p1 = m.Parameter(1); |
+ Node* const p2 = m.Parameter(2); |
+ Node* const n = m.Float32Add(p0, m.Float32Mul(p1, p2)); |
+ m.Return(n); |
+ Stream s = m.Build(); |
+ ASSERT_EQ(1U, s.size()); |
+ if (kArchVariant == kMips64r2) { |
+ EXPECT_EQ(kMips64MaddS, s[0]->arch_opcode()); |
+ } else if (kArchVariant == kMips64r6) { |
+ EXPECT_EQ(kMips64MaddfS, s[0]->arch_opcode()); |
+ } |
+ ASSERT_EQ(3U, s[0]->InputCount()); |
+ EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
+ EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1))); |
+ EXPECT_EQ(s.ToVreg(p2), s.ToVreg(s[0]->InputAt(2))); |
+ ASSERT_EQ(1U, s[0]->OutputCount()); |
+ if (kArchVariant == kMips64r2) { |
+ EXPECT_FALSE( |
+ UnallocatedOperand::cast(s[0]->Output())->HasSameAsInputPolicy()); |
+ } else if (kArchVariant == kMips64r6) { |
+ EXPECT_TRUE( |
+ UnallocatedOperand::cast(s[0]->Output())->HasSameAsInputPolicy()); |
+ } |
+ EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
+ EXPECT_EQ(kFlags_none, s[0]->flags_mode()); |
+ } |
+} |
+ |
+TEST_F(InstructionSelectorTest, Float64AddWithFloat64Mul) { |
+ { |
+ StreamBuilder m(this, MachineType::Float64(), MachineType::Float64(), |
+ MachineType::Float64(), MachineType::Float64()); |
+ Node* const p0 = m.Parameter(0); |
+ Node* const p1 = m.Parameter(1); |
+ Node* const p2 = m.Parameter(2); |
+ Node* const n = m.Float64Add(m.Float64Mul(p0, p1), p2); |
+ m.Return(n); |
+ Stream s = m.Build(); |
+ ASSERT_EQ(1U, s.size()); |
+ if (kArchVariant == kMips64r2) { |
+ EXPECT_EQ(kMips64MaddD, s[0]->arch_opcode()); |
+ } else if (kArchVariant == kMips64r6) { |
+ EXPECT_EQ(kMips64MaddfD, s[0]->arch_opcode()); |
+ } |
+ ASSERT_EQ(3U, s[0]->InputCount()); |
+ EXPECT_EQ(s.ToVreg(p2), s.ToVreg(s[0]->InputAt(0))); |
+ EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(1))); |
+ EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(2))); |
+ ASSERT_EQ(1U, s[0]->OutputCount()); |
+ if (kArchVariant == kMips64r2) { |
+ EXPECT_FALSE( |
+ UnallocatedOperand::cast(s[0]->Output())->HasSameAsInputPolicy()); |
+ } else if (kArchVariant == kMips64r6) { |
+ EXPECT_TRUE( |
+ UnallocatedOperand::cast(s[0]->Output())->HasSameAsInputPolicy()); |
+ } |
+ EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
+ EXPECT_EQ(kFlags_none, s[0]->flags_mode()); |
+ } |
+ { |
+ StreamBuilder m(this, MachineType::Float64(), MachineType::Float64(), |
+ MachineType::Float64(), MachineType::Float64()); |
+ Node* const p0 = m.Parameter(0); |
+ Node* const p1 = m.Parameter(1); |
+ Node* const p2 = m.Parameter(2); |
+ Node* const n = m.Float64Add(p0, m.Float64Mul(p1, p2)); |
+ m.Return(n); |
+ Stream s = m.Build(); |
+ ASSERT_EQ(1U, s.size()); |
+ if (kArchVariant == kMips64r2) { |
+ EXPECT_EQ(kMips64MaddD, s[0]->arch_opcode()); |
+ } else if (kArchVariant == kMips64r6) { |
+ EXPECT_EQ(kMips64MaddfD, s[0]->arch_opcode()); |
+ } |
+ ASSERT_EQ(3U, s[0]->InputCount()); |
+ EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
+ EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1))); |
+ EXPECT_EQ(s.ToVreg(p2), s.ToVreg(s[0]->InputAt(2))); |
+ ASSERT_EQ(1U, s[0]->OutputCount()); |
+ if (kArchVariant == kMips64r2) { |
+ EXPECT_FALSE( |
+ UnallocatedOperand::cast(s[0]->Output())->HasSameAsInputPolicy()); |
+ } else if (kArchVariant == kMips64r6) { |
+ EXPECT_TRUE( |
+ UnallocatedOperand::cast(s[0]->Output())->HasSameAsInputPolicy()); |
+ } |
+ EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
+ EXPECT_EQ(kFlags_none, s[0]->flags_mode()); |
+ } |
+} |
+ |
+TEST_F(InstructionSelectorTest, Float32SubWithFloat32Mul) { |
+ StreamBuilder m(this, MachineType::Float32(), MachineType::Float32(), |
+ MachineType::Float32(), MachineType::Float32()); |
+ Node* const p0 = m.Parameter(0); |
+ Node* const p1 = m.Parameter(1); |
+ Node* const p2 = m.Parameter(2); |
+ Node* n; |
+ if (kArchVariant == kMips64r2) { |
+ n = m.Float32Sub(m.Float32Mul(p1, p2), p0); |
+ } else if (kArchVariant == kMips64r6) { |
+ n = m.Float32Sub(p0, m.Float32Mul(p1, p2)); |
+ } |
+ m.Return(n); |
+ Stream s = m.Build(); |
+ ASSERT_EQ(1U, s.size()); |
+ if (kArchVariant == kMips64r2) { |
+ EXPECT_EQ(kMips64MsubS, s[0]->arch_opcode()); |
+ } else if (kArchVariant == kMips64r6) { |
+ EXPECT_EQ(kMips64MsubfS, s[0]->arch_opcode()); |
+ } |
+ ASSERT_EQ(3U, s[0]->InputCount()); |
+ EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
+ EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1))); |
+ EXPECT_EQ(s.ToVreg(p2), s.ToVreg(s[0]->InputAt(2))); |
+ ASSERT_EQ(1U, s[0]->OutputCount()); |
+ if (kArchVariant == kMips64r2) { |
+ EXPECT_FALSE( |
+ UnallocatedOperand::cast(s[0]->Output())->HasSameAsInputPolicy()); |
+ } else if (kArchVariant == kMips64r6) { |
+ EXPECT_TRUE( |
+ UnallocatedOperand::cast(s[0]->Output())->HasSameAsInputPolicy()); |
+ } |
+ EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
+ EXPECT_EQ(kFlags_none, s[0]->flags_mode()); |
+} |
+ |
+TEST_F(InstructionSelectorTest, Float64SubWithFloat64Mul) { |
+ StreamBuilder m(this, MachineType::Float64(), MachineType::Float64(), |
+ MachineType::Float64(), MachineType::Float64()); |
+ Node* const p0 = m.Parameter(0); |
+ Node* const p1 = m.Parameter(1); |
+ Node* const p2 = m.Parameter(2); |
+ Node* n; |
+ if (kArchVariant == kMips64r2) { |
+ n = m.Float64Sub(m.Float64Mul(p1, p2), p0); |
+ } else if (kArchVariant == kMips64r6) { |
+ n = m.Float64Sub(p0, m.Float64Mul(p1, p2)); |
+ } |
+ m.Return(n); |
+ Stream s = m.Build(); |
+ ASSERT_EQ(1U, s.size()); |
+ if (kArchVariant == kMips64r2) { |
+ EXPECT_EQ(kMips64MsubD, s[0]->arch_opcode()); |
+ } else if (kArchVariant == kMips64r6) { |
+ EXPECT_EQ(kMips64MsubfD, s[0]->arch_opcode()); |
+ } |
+ ASSERT_EQ(3U, s[0]->InputCount()); |
+ EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
+ EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1))); |
+ EXPECT_EQ(s.ToVreg(p2), s.ToVreg(s[0]->InputAt(2))); |
+ ASSERT_EQ(1U, s[0]->OutputCount()); |
+ if (kArchVariant == kMips64r2) { |
+ EXPECT_FALSE( |
+ UnallocatedOperand::cast(s[0]->Output())->HasSameAsInputPolicy()); |
+ } else if (kArchVariant == kMips64r6) { |
+ EXPECT_TRUE( |
+ UnallocatedOperand::cast(s[0]->Output())->HasSameAsInputPolicy()); |
+ } |
+ EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
+ EXPECT_EQ(kFlags_none, s[0]->flags_mode()); |
+} |
TEST_F(InstructionSelectorTest, Float64Max) { |
StreamBuilder m(this, MachineType::Float64(), MachineType::Float64(), |