Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: test/unittests/compiler/mips/instruction-selector-mips-unittest.cc

Issue 1520503002: MIPS: [turbofan] Optimize Float32 to Int32 rep. changes with Float32 round ops. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file 3 // found in the LICENSE file
4 4
5 #include "test/unittests/compiler/instruction-selector-unittest.h" 5 #include "test/unittests/compiler/instruction-selector-unittest.h"
6 6
7 namespace v8 { 7 namespace v8 {
8 namespace internal { 8 namespace internal {
9 namespace compiler { 9 namespace compiler {
10 10
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 kMipsTruncWD, MachineType::Float64()}, 237 kMipsTruncWD, MachineType::Float64()},
238 MachineType::Int32()}, 238 MachineType::Int32()},
239 239
240 // mips instruction: trunc_uw_d 240 // mips instruction: trunc_uw_d
241 {{&RawMachineAssembler::ChangeFloat64ToUint32, "ChangeFloat64ToUint32", 241 {{&RawMachineAssembler::ChangeFloat64ToUint32, "ChangeFloat64ToUint32",
242 kMipsTruncUwD, MachineType::Float64()}, 242 kMipsTruncUwD, MachineType::Float64()},
243 MachineType::Int32()}}; 243 MachineType::Int32()}};
244 244
245 const Conversion kFloat64RoundInstructions[] = { 245 const Conversion kFloat64RoundInstructions[] = {
246 {{&RawMachineAssembler::Float64RoundUp, "Float64RoundUp", kMipsCeilWD, 246 {{&RawMachineAssembler::Float64RoundUp, "Float64RoundUp", kMipsCeilWD,
247 MachineType::Float64()}, 247 MachineType::Int32()},
248 MachineType::Int32()}, 248 MachineType::Float64()},
249 {{&RawMachineAssembler::Float64RoundDown, "Float64RoundDown", kMipsFloorWD, 249 {{&RawMachineAssembler::Float64RoundDown, "Float64RoundDown", kMipsFloorWD,
250 MachineType::Float64()}, 250 MachineType::Int32()},
251 MachineType::Int32()}, 251 MachineType::Float64()},
252 {{&RawMachineAssembler::Float64RoundTiesEven, "Float64RoundTiesEven", 252 {{&RawMachineAssembler::Float64RoundTiesEven, "Float64RoundTiesEven",
253 kMipsRoundWD, MachineType::Float64()}, 253 kMipsRoundWD, MachineType::Int32()},
254 MachineType::Int32()}, 254 MachineType::Float64()},
255 {{&RawMachineAssembler::Float64RoundTruncate, "Float64RoundTruncate", 255 {{&RawMachineAssembler::Float64RoundTruncate, "Float64RoundTruncate",
256 kMipsTruncWD, MachineType::Float64()}, 256 kMipsTruncWD, MachineType::Int32()},
257 MachineType::Int32()}}; 257 MachineType::Float64()}};
258
259 const Conversion kFloat32RoundInstructions[] = {
260 {{&RawMachineAssembler::Float32RoundUp, "Float32RoundUp", kMipsCeilWS,
261 MachineType::Int32()},
262 MachineType::Float32()},
263 {{&RawMachineAssembler::Float32RoundDown, "Float32RoundDown", kMipsFloorWS,
264 MachineType::Int32()},
265 MachineType::Float32()},
266 {{&RawMachineAssembler::Float32RoundTiesEven, "Float32RoundTiesEven",
267 kMipsRoundWS, MachineType::Int32()},
268 MachineType::Float32()},
269 {{&RawMachineAssembler::Float32RoundTruncate, "Float32RoundTruncate",
270 kMipsTruncWS, MachineType::Int32()},
271 MachineType::Float32()}};
258 272
259 } // namespace 273 } // namespace
260 274
261 275
262 typedef InstructionSelectorTestWithParam<FPCmp> InstructionSelectorFPCmpTest; 276 typedef InstructionSelectorTestWithParam<FPCmp> InstructionSelectorFPCmpTest;
263 277
264 278
265 TEST_P(InstructionSelectorFPCmpTest, Parameter) { 279 TEST_P(InstructionSelectorFPCmpTest, Parameter) {
266 const FPCmp cmp = GetParam(); 280 const FPCmp cmp = GetParam();
267 StreamBuilder m(this, MachineType::Int32(), cmp.mi.machine_type, 281 StreamBuilder m(this, MachineType::Int32(), cmp.mi.machine_type,
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 ASSERT_EQ(1U, s[0]->InputCount()); 717 ASSERT_EQ(1U, s[0]->InputCount());
704 EXPECT_EQ(1U, s[0]->OutputCount()); 718 EXPECT_EQ(1U, s[0]->OutputCount());
705 } 719 }
706 } 720 }
707 721
708 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, 722 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest,
709 CombineChangeFloat64ToInt32WithRoundFloat64, 723 CombineChangeFloat64ToInt32WithRoundFloat64,
710 ::testing::ValuesIn(kFloat64RoundInstructions)); 724 ::testing::ValuesIn(kFloat64RoundInstructions));
711 725
712 726
727 typedef InstructionSelectorTestWithParam<Conversion>
728 CombineChangeFloat32ToInt32WithRoundFloat32;
729
730 TEST_P(CombineChangeFloat32ToInt32WithRoundFloat32, Parameter) {
731 {
732 const Conversion conv = GetParam();
733 StreamBuilder m(this, conv.mi.machine_type, conv.src_machine_type);
734 m.Return(m.ChangeFloat64ToInt32(
735 m.ChangeFloat32ToFloat64((m.*conv.mi.constructor)(m.Parameter(0)))));
736 Stream s = m.Build();
737 ASSERT_EQ(1U, s.size());
738 EXPECT_EQ(conv.mi.arch_opcode, s[0]->arch_opcode());
739 EXPECT_EQ(kMode_None, s[0]->addressing_mode());
740 ASSERT_EQ(1U, s[0]->InputCount());
741 EXPECT_EQ(1U, s[0]->OutputCount());
742 }
743 }
744
745 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest,
746 CombineChangeFloat32ToInt32WithRoundFloat32,
747 ::testing::ValuesIn(kFloat32RoundInstructions));
748
749
750 TEST_F(InstructionSelectorTest, ChangeFloat64ToInt32OfChangeFloat32ToFloat64) {
751 {
752 StreamBuilder m(this, MachineType::Int32(), MachineType::Float32());
753 m.Return(m.ChangeFloat64ToInt32(m.ChangeFloat32ToFloat64(m.Parameter(0))));
754 Stream s = m.Build();
755 ASSERT_EQ(1U, s.size());
756 EXPECT_EQ(kMipsTruncWS, s[0]->arch_opcode());
757 EXPECT_EQ(kMode_None, s[0]->addressing_mode());
758 ASSERT_EQ(1U, s[0]->InputCount());
759 EXPECT_EQ(1U, s[0]->OutputCount());
760 }
761 }
762
763
764 TEST_F(InstructionSelectorTest,
765 TruncateFloat64ToFloat32OfChangeInt32ToFloat64) {
766 {
767 StreamBuilder m(this, MachineType::Float32(), MachineType::Int32());
768 m.Return(
769 m.TruncateFloat64ToFloat32(m.ChangeInt32ToFloat64(m.Parameter(0))));
770 Stream s = m.Build();
771 ASSERT_EQ(1U, s.size());
772 EXPECT_EQ(kMipsCvtSW, s[0]->arch_opcode());
773 EXPECT_EQ(kMode_None, s[0]->addressing_mode());
774 ASSERT_EQ(1U, s[0]->InputCount());
775 EXPECT_EQ(1U, s[0]->OutputCount());
776 }
777 }
778
779
713 // ---------------------------------------------------------------------------- 780 // ----------------------------------------------------------------------------
714 // Loads and stores. 781 // Loads and stores.
715 // ---------------------------------------------------------------------------- 782 // ----------------------------------------------------------------------------
716 783
717 namespace { 784 namespace {
718 785
719 struct MemoryAccess { 786 struct MemoryAccess {
720 MachineType type; 787 MachineType type;
721 ArchOpcode load_opcode; 788 ArchOpcode load_opcode;
722 ArchOpcode store_opcode; 789 ArchOpcode store_opcode;
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
1147 EXPECT_EQ(kMipsFloat64Min, s[0]->arch_opcode()); 1214 EXPECT_EQ(kMipsFloat64Min, s[0]->arch_opcode());
1148 ASSERT_EQ(2U, s[0]->InputCount()); 1215 ASSERT_EQ(2U, s[0]->InputCount());
1149 ASSERT_EQ(1U, s[0]->OutputCount()); 1216 ASSERT_EQ(1U, s[0]->OutputCount());
1150 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); 1217 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output()));
1151 } 1218 }
1152 1219
1153 1220
1154 } // namespace compiler 1221 } // namespace compiler
1155 } // namespace internal 1222 } // namespace internal
1156 } // namespace v8 1223 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698