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 b88d62341b82cc05cf5c70cbd331c806cab1e1a0..d9cd96f47108be5a33fd3e336162125a95b78555 100644 |
--- a/test/unittests/compiler/mips64/instruction-selector-mips64-unittest.cc |
+++ b/test/unittests/compiler/mips64/instruction-selector-mips64-unittest.cc |
@@ -262,17 +262,31 @@ const Conversion kConversionInstructions[] = { |
const Conversion kFloat64RoundInstructions[] = { |
{{&RawMachineAssembler::Float64RoundUp, "Float64RoundUp", kMips64CeilWD, |
- MachineType::Float64()}, |
- MachineType::Int32()}, |
+ MachineType::Int32()}, |
+ MachineType::Float64()}, |
{{&RawMachineAssembler::Float64RoundDown, "Float64RoundDown", |
- kMips64FloorWD, MachineType::Float64()}, |
- MachineType::Int32()}, |
+ kMips64FloorWD, MachineType::Int32()}, |
+ MachineType::Float64()}, |
{{&RawMachineAssembler::Float64RoundTiesEven, "Float64RoundTiesEven", |
- kMips64RoundWD, MachineType::Float64()}, |
- MachineType::Int32()}, |
+ kMips64RoundWD, MachineType::Int32()}, |
+ MachineType::Float64()}, |
{{&RawMachineAssembler::Float64RoundTruncate, "Float64RoundTruncate", |
- kMips64TruncWD, MachineType::Float64()}, |
- MachineType::Int32()}}; |
+ kMips64TruncWD, MachineType::Int32()}, |
+ MachineType::Float64()}}; |
+ |
+const Conversion kFloat32RoundInstructions[] = { |
+ {{&RawMachineAssembler::Float32RoundUp, "Float32RoundUp", kMips64CeilWS, |
+ MachineType::Int32()}, |
+ MachineType::Float32()}, |
+ {{&RawMachineAssembler::Float32RoundDown, "Float32RoundDown", |
+ kMips64FloorWS, MachineType::Int32()}, |
+ MachineType::Float32()}, |
+ {{&RawMachineAssembler::Float32RoundTiesEven, "Float32RoundTiesEven", |
+ kMips64RoundWS, MachineType::Int32()}, |
+ MachineType::Float32()}, |
+ {{&RawMachineAssembler::Float32RoundTruncate, "Float32RoundTruncate", |
+ kMips64TruncWS, MachineType::Int32()}, |
+ MachineType::Float32()}}; |
} // namespace |
@@ -881,6 +895,58 @@ INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, |
CombineChangeFloat64ToInt32WithRoundFloat64, |
::testing::ValuesIn(kFloat64RoundInstructions)); |
+typedef InstructionSelectorTestWithParam<Conversion> |
+ CombineChangeFloat32ToInt32WithRoundFloat32; |
+ |
+TEST_P(CombineChangeFloat32ToInt32WithRoundFloat32, Parameter) { |
+ { |
+ const Conversion conv = GetParam(); |
+ StreamBuilder m(this, conv.mi.machine_type, conv.src_machine_type); |
+ m.Return(m.ChangeFloat64ToInt32( |
+ m.ChangeFloat32ToFloat64((m.*conv.mi.constructor)(m.Parameter(0))))); |
+ Stream s = m.Build(); |
+ ASSERT_EQ(1U, s.size()); |
+ EXPECT_EQ(conv.mi.arch_opcode, s[0]->arch_opcode()); |
+ EXPECT_EQ(kMode_None, s[0]->addressing_mode()); |
+ ASSERT_EQ(1U, s[0]->InputCount()); |
+ EXPECT_EQ(1U, s[0]->OutputCount()); |
+ } |
+} |
+ |
+INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, |
+ CombineChangeFloat32ToInt32WithRoundFloat32, |
+ ::testing::ValuesIn(kFloat32RoundInstructions)); |
+ |
+ |
+TEST_F(InstructionSelectorTest, ChangeFloat64ToInt32OfChangeFloat32ToFloat64) { |
+ { |
+ StreamBuilder m(this, MachineType::Int32(), MachineType::Float32()); |
+ m.Return(m.ChangeFloat64ToInt32(m.ChangeFloat32ToFloat64(m.Parameter(0)))); |
+ Stream s = m.Build(); |
+ ASSERT_EQ(1U, s.size()); |
+ EXPECT_EQ(kMips64TruncWS, s[0]->arch_opcode()); |
+ EXPECT_EQ(kMode_None, s[0]->addressing_mode()); |
+ ASSERT_EQ(1U, s[0]->InputCount()); |
+ EXPECT_EQ(1U, s[0]->OutputCount()); |
+ } |
+} |
+ |
+ |
+TEST_F(InstructionSelectorTest, |
+ TruncateFloat64ToFloat32OfChangeInt32ToFloat64) { |
+ { |
+ StreamBuilder m(this, MachineType::Float32(), MachineType::Int32()); |
+ m.Return( |
+ m.TruncateFloat64ToFloat32(m.ChangeInt32ToFloat64(m.Parameter(0)))); |
+ Stream s = m.Build(); |
+ ASSERT_EQ(1U, s.size()); |
+ EXPECT_EQ(kMips64CvtSW, s[0]->arch_opcode()); |
+ EXPECT_EQ(kMode_None, s[0]->addressing_mode()); |
+ ASSERT_EQ(1U, s[0]->InputCount()); |
+ EXPECT_EQ(1U, s[0]->OutputCount()); |
+ } |
+} |
+ |
TEST_F(InstructionSelectorTest, CombineShiftsWithMul) { |
{ |