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

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

Issue 1066393002: [turbofan] Add new Float32Abs and Float64Abs operators. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix comment. Created 5 years, 8 months 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
« no previous file with comments | « test/unittests/compiler/node-test-utils.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "src/compiler/node-matchers.h" 7 #include "src/compiler/node-matchers.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
(...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 EXPECT_EQ(kMode_M8, s[0]->addressing_mode()); 989 EXPECT_EQ(kMode_M8, s[0]->addressing_mode());
990 ASSERT_EQ(1U, s[0]->InputCount()); 990 ASSERT_EQ(1U, s[0]->InputCount());
991 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); 991 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
992 } 992 }
993 993
994 994
995 // ----------------------------------------------------------------------------- 995 // -----------------------------------------------------------------------------
996 // Floating point operations. 996 // Floating point operations.
997 997
998 998
999 TEST_F(InstructionSelectorTest, Float32Abs) {
1000 StreamBuilder m(this, kMachFloat32, kMachFloat32);
1001 Node* const p0 = m.Parameter(0);
1002 Node* const n = m.Float32Abs(p0);
1003 m.Return(n);
1004 Stream s = m.Build();
1005 ASSERT_EQ(1U, s.size());
1006 EXPECT_EQ(kSSEFloat32Abs, s[0]->arch_opcode());
1007 ASSERT_EQ(1U, s[0]->InputCount());
1008 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
1009 ASSERT_EQ(1U, s[0]->OutputCount());
1010 EXPECT_TRUE(s.IsSameAsFirst(s[0]->Output()));
1011 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output()));
1012 EXPECT_EQ(kFlags_none, s[0]->flags_mode());
1013 }
1014
1015
1016 TEST_F(InstructionSelectorTest, Float64Abs) {
1017 StreamBuilder m(this, kMachFloat64, kMachFloat64);
1018 Node* const p0 = m.Parameter(0);
1019 Node* const n = m.Float64Abs(p0);
1020 m.Return(n);
1021 Stream s = m.Build();
1022 ASSERT_EQ(1U, s.size());
1023 EXPECT_EQ(kSSEFloat64Abs, s[0]->arch_opcode());
1024 ASSERT_EQ(1U, s[0]->InputCount());
1025 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
1026 ASSERT_EQ(1U, s[0]->OutputCount());
1027 EXPECT_TRUE(s.IsSameAsFirst(s[0]->Output()));
1028 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output()));
1029 EXPECT_EQ(kFlags_none, s[0]->flags_mode());
1030 }
1031
1032
999 TEST_F(InstructionSelectorTest, Float64BinopArithmetic) { 1033 TEST_F(InstructionSelectorTest, Float64BinopArithmetic) {
1000 { 1034 {
1001 StreamBuilder m(this, kMachFloat64, kMachFloat64, kMachFloat64); 1035 StreamBuilder m(this, kMachFloat64, kMachFloat64, kMachFloat64);
1002 Node* add = m.Float64Add(m.Parameter(0), m.Parameter(1)); 1036 Node* add = m.Float64Add(m.Parameter(0), m.Parameter(1));
1003 Node* mul = m.Float64Mul(add, m.Parameter(1)); 1037 Node* mul = m.Float64Mul(add, m.Parameter(1));
1004 Node* sub = m.Float64Sub(mul, add); 1038 Node* sub = m.Float64Sub(mul, add);
1005 Node* ret = m.Float64Div(mul, sub); 1039 Node* ret = m.Float64Div(mul, sub);
1006 m.Return(ret); 1040 m.Return(ret);
1007 Stream s = m.Build(AVX); 1041 Stream s = m.Build(AVX);
1008 ASSERT_EQ(4U, s.size()); 1042 ASSERT_EQ(4U, s.size());
(...skipping 12 matching lines...) Expand all
1021 Stream s = m.Build(); 1055 Stream s = m.Build();
1022 ASSERT_EQ(4U, s.size()); 1056 ASSERT_EQ(4U, s.size());
1023 EXPECT_EQ(kSSEFloat64Add, s[0]->arch_opcode()); 1057 EXPECT_EQ(kSSEFloat64Add, s[0]->arch_opcode());
1024 EXPECT_EQ(kSSEFloat64Mul, s[1]->arch_opcode()); 1058 EXPECT_EQ(kSSEFloat64Mul, s[1]->arch_opcode());
1025 EXPECT_EQ(kSSEFloat64Sub, s[2]->arch_opcode()); 1059 EXPECT_EQ(kSSEFloat64Sub, s[2]->arch_opcode());
1026 EXPECT_EQ(kSSEFloat64Div, s[3]->arch_opcode()); 1060 EXPECT_EQ(kSSEFloat64Div, s[3]->arch_opcode());
1027 } 1061 }
1028 } 1062 }
1029 1063
1030 1064
1065 TEST_F(InstructionSelectorTest, Float32SubWithMinusZeroAndParameter) {
1066 StreamBuilder m(this, kMachFloat32, kMachFloat32);
1067 Node* const p0 = m.Parameter(0);
1068 Node* const n = m.Float32Sub(m.Float32Constant(-0.0f), p0);
1069 m.Return(n);
1070 Stream s = m.Build();
1071 ASSERT_EQ(1U, s.size());
1072 EXPECT_EQ(kSSEFloat32Neg, s[0]->arch_opcode());
1073 ASSERT_EQ(1U, s[0]->InputCount());
1074 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
1075 ASSERT_EQ(1U, s[0]->OutputCount());
1076 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output()));
1077 EXPECT_EQ(kFlags_none, s[0]->flags_mode());
1078 }
1079
1080
1031 TEST_F(InstructionSelectorTest, Float64SubWithMinusZeroAndParameter) { 1081 TEST_F(InstructionSelectorTest, Float64SubWithMinusZeroAndParameter) {
1032 StreamBuilder m(this, kMachFloat64, kMachFloat64); 1082 StreamBuilder m(this, kMachFloat64, kMachFloat64);
1033 Node* const p0 = m.Parameter(0); 1083 Node* const p0 = m.Parameter(0);
1034 Node* const n = m.Float64Sub(m.Float64Constant(-0.0), p0); 1084 Node* const n = m.Float64Sub(m.Float64Constant(-0.0), p0);
1035 m.Return(n); 1085 m.Return(n);
1036 Stream s = m.Build(); 1086 Stream s = m.Build();
1037 ASSERT_EQ(1U, s.size()); 1087 ASSERT_EQ(1U, s.size());
1038 EXPECT_EQ(kSSEFloat64Neg, s[0]->arch_opcode()); 1088 EXPECT_EQ(kSSEFloat64Neg, s[0]->arch_opcode());
1039 ASSERT_EQ(1U, s[0]->InputCount()); 1089 ASSERT_EQ(1U, s[0]->InputCount());
1040 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); 1090 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1175 EXPECT_EQ(kX64Lzcnt32, s[0]->arch_opcode()); 1225 EXPECT_EQ(kX64Lzcnt32, s[0]->arch_opcode());
1176 ASSERT_EQ(1U, s[0]->InputCount()); 1226 ASSERT_EQ(1U, s[0]->InputCount());
1177 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); 1227 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
1178 ASSERT_EQ(1U, s[0]->OutputCount()); 1228 ASSERT_EQ(1U, s[0]->OutputCount());
1179 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); 1229 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output()));
1180 } 1230 }
1181 1231
1182 } // namespace compiler 1232 } // namespace compiler
1183 } // namespace internal 1233 } // namespace internal
1184 } // namespace v8 1234 } // namespace v8
OLDNEW
« no previous file with comments | « test/unittests/compiler/node-test-utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698