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

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

Issue 1356283003: [arm64] Optimize fcmp when lhs operand is #0.0 (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 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 | « src/compiler/x87/code-generator-x87.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 namespace v8 { 7 namespace v8 {
8 namespace internal { 8 namespace internal {
9 namespace compiler { 9 namespace compiler {
10 10
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 } 228 }
229 229
230 230
231 // ARM64 FP comparison instructions. 231 // ARM64 FP comparison instructions.
232 const FPCmp kFPCmpInstructions[] = { 232 const FPCmp kFPCmpInstructions[] = {
233 {{&RawMachineAssembler::Float64Equal, "Float64Equal", kArm64Float64Cmp, 233 {{&RawMachineAssembler::Float64Equal, "Float64Equal", kArm64Float64Cmp,
234 kMachFloat64}, 234 kMachFloat64},
235 kEqual}, 235 kEqual},
236 {{&RawMachineAssembler::Float64LessThan, "Float64LessThan", 236 {{&RawMachineAssembler::Float64LessThan, "Float64LessThan",
237 kArm64Float64Cmp, kMachFloat64}, 237 kArm64Float64Cmp, kMachFloat64},
238 kUnsignedLessThan}, 238 kFloatLessThan},
239 {{&RawMachineAssembler::Float64LessThanOrEqual, "Float64LessThanOrEqual", 239 {{&RawMachineAssembler::Float64LessThanOrEqual, "Float64LessThanOrEqual",
240 kArm64Float64Cmp, kMachFloat64}, 240 kArm64Float64Cmp, kMachFloat64},
241 kUnsignedLessThanOrEqual}}; 241 kFloatLessThanOrEqual},
242 {{&RawMachineAssembler::Float32Equal, "Float32Equal", kArm64Float32Cmp,
243 kMachFloat32},
244 kEqual},
245 {{&RawMachineAssembler::Float32LessThan, "Float32LessThan",
246 kArm64Float32Cmp, kMachFloat32},
247 kFloatLessThan},
248 {{&RawMachineAssembler::Float32LessThanOrEqual, "Float32LessThanOrEqual",
249 kArm64Float32Cmp, kMachFloat32},
250 kFloatLessThanOrEqual}};
242 251
243 252
244 struct Conversion { 253 struct Conversion {
245 // The machine_type field in MachInst1 represents the destination type. 254 // The machine_type field in MachInst1 represents the destination type.
246 MachInst1 mi; 255 MachInst1 mi;
247 MachineType src_machine_type; 256 MachineType src_machine_type;
248 }; 257 };
249 258
250 259
251 std::ostream& operator<<(std::ostream& os, const Conversion& conv) { 260 std::ostream& operator<<(std::ostream& os, const Conversion& conv) {
(...skipping 1654 matching lines...) Expand 10 before | Expand all | Expand 10 after
1906 EXPECT_EQ(2U, s[0]->InputCount()); 1915 EXPECT_EQ(2U, s[0]->InputCount());
1907 EXPECT_EQ(1U, s[0]->OutputCount()); 1916 EXPECT_EQ(1U, s[0]->OutputCount());
1908 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); 1917 EXPECT_EQ(kFlags_set, s[0]->flags_mode());
1909 EXPECT_EQ(cmp.cond, s[0]->flags_condition()); 1918 EXPECT_EQ(cmp.cond, s[0]->flags_condition());
1910 } 1919 }
1911 1920
1912 1921
1913 TEST_P(InstructionSelectorFPCmpTest, WithImmediateZeroOnRight) { 1922 TEST_P(InstructionSelectorFPCmpTest, WithImmediateZeroOnRight) {
1914 const FPCmp cmp = GetParam(); 1923 const FPCmp cmp = GetParam();
1915 StreamBuilder m(this, kMachInt32, cmp.mi.machine_type); 1924 StreamBuilder m(this, kMachInt32, cmp.mi.machine_type);
1916 m.Return((m.*cmp.mi.constructor)(m.Parameter(0), m.Float64Constant(0.0))); 1925 if (cmp.mi.machine_type == kMachFloat64) {
1926 m.Return((m.*cmp.mi.constructor)(m.Parameter(0), m.Float64Constant(0.0)));
1927 } else {
1928 m.Return((m.*cmp.mi.constructor)(m.Parameter(0), m.Float32Constant(0.0f)));
1929 }
1917 Stream s = m.Build(); 1930 Stream s = m.Build();
1918 ASSERT_EQ(1U, s.size()); 1931 ASSERT_EQ(1U, s.size());
1919 EXPECT_EQ(cmp.mi.arch_opcode, s[0]->arch_opcode()); 1932 EXPECT_EQ(cmp.mi.arch_opcode, s[0]->arch_opcode());
1920 EXPECT_EQ(2U, s[0]->InputCount()); 1933 EXPECT_EQ(2U, s[0]->InputCount());
1921 EXPECT_TRUE(s[0]->InputAt(1)->IsImmediate()); 1934 EXPECT_TRUE(s[0]->InputAt(1)->IsImmediate());
1922 EXPECT_EQ(1U, s[0]->OutputCount()); 1935 EXPECT_EQ(1U, s[0]->OutputCount());
1923 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); 1936 EXPECT_EQ(kFlags_set, s[0]->flags_mode());
1924 EXPECT_EQ(cmp.cond, s[0]->flags_condition()); 1937 EXPECT_EQ(cmp.cond, s[0]->flags_condition());
1925 } 1938 }
1926 1939
1927 1940
1941 TEST_P(InstructionSelectorFPCmpTest, WithImmediateZeroOnLeft) {
1942 const FPCmp cmp = GetParam();
1943 StreamBuilder m(this, kMachInt32, cmp.mi.machine_type);
1944 if (cmp.mi.machine_type == kMachFloat64) {
1945 m.Return((m.*cmp.mi.constructor)(m.Float64Constant(0.0), m.Parameter(0)));
1946 } else {
1947 m.Return((m.*cmp.mi.constructor)(m.Float32Constant(0.0f), m.Parameter(0)));
1948 }
1949 Stream s = m.Build();
1950 ASSERT_EQ(1U, s.size());
1951 EXPECT_EQ(cmp.mi.arch_opcode, s[0]->arch_opcode());
1952 EXPECT_EQ(2U, s[0]->InputCount());
1953 EXPECT_TRUE(s[0]->InputAt(1)->IsImmediate());
1954 EXPECT_EQ(1U, s[0]->OutputCount());
1955 EXPECT_EQ(kFlags_set, s[0]->flags_mode());
1956 EXPECT_EQ(CommuteFlagsCondition(cmp.cond), s[0]->flags_condition());
1957 }
1958
1959
1928 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, InstructionSelectorFPCmpTest, 1960 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, InstructionSelectorFPCmpTest,
1929 ::testing::ValuesIn(kFPCmpInstructions)); 1961 ::testing::ValuesIn(kFPCmpInstructions));
1930 1962
1931 1963
1932 TEST_F(InstructionSelectorTest, Float64EqualWithImmediateZeroOnLeft) {
1933 StreamBuilder m(this, kMachInt32, kMachFloat64);
1934 m.Return(m.Float64Equal(m.Float64Constant(0.0), m.Parameter(0)));
1935 Stream s = m.Build();
1936 ASSERT_EQ(1U, s.size());
1937 EXPECT_EQ(kArm64Float64Cmp, s[0]->arch_opcode());
1938 EXPECT_EQ(2U, s[0]->InputCount());
1939 EXPECT_TRUE(s[0]->InputAt(1)->IsImmediate());
1940 EXPECT_EQ(1U, s[0]->OutputCount());
1941 EXPECT_EQ(kFlags_set, s[0]->flags_mode());
1942 EXPECT_EQ(kEqual, s[0]->flags_condition());
1943 }
1944
1945
1946 // ----------------------------------------------------------------------------- 1964 // -----------------------------------------------------------------------------
1947 // Conversions. 1965 // Conversions.
1948 1966
1949 typedef InstructionSelectorTestWithParam<Conversion> 1967 typedef InstructionSelectorTestWithParam<Conversion>
1950 InstructionSelectorConversionTest; 1968 InstructionSelectorConversionTest;
1951 1969
1952 1970
1953 TEST_P(InstructionSelectorConversionTest, Parameter) { 1971 TEST_P(InstructionSelectorConversionTest, Parameter) {
1954 const Conversion conv = GetParam(); 1972 const Conversion conv = GetParam();
1955 StreamBuilder m(this, conv.mi.machine_type, conv.src_machine_type); 1973 StreamBuilder m(this, conv.mi.machine_type, conv.src_machine_type);
(...skipping 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after
3031 EXPECT_EQ(kArm64Float64Neg, s[0]->arch_opcode()); 3049 EXPECT_EQ(kArm64Float64Neg, s[0]->arch_opcode());
3032 ASSERT_EQ(1U, s[0]->InputCount()); 3050 ASSERT_EQ(1U, s[0]->InputCount());
3033 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); 3051 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
3034 ASSERT_EQ(1U, s[0]->OutputCount()); 3052 ASSERT_EQ(1U, s[0]->OutputCount());
3035 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); 3053 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output()));
3036 } 3054 }
3037 3055
3038 } // namespace compiler 3056 } // namespace compiler
3039 } // namespace internal 3057 } // namespace internal
3040 } // namespace v8 3058 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/x87/code-generator-x87.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698