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

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

Issue 1360603003: [arm64] Implement Float(32|64)(Min|Max) using fcsel. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: More local solution, as suggested. Created 5 years, 1 month 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 3095 matching lines...) Expand 10 before | Expand all | Expand 10 after
3106 m.Return(n); 3106 m.Return(n);
3107 Stream s = m.Build(); 3107 Stream s = m.Build();
3108 ASSERT_EQ(1U, s.size()); 3108 ASSERT_EQ(1U, s.size());
3109 EXPECT_EQ(kArm64Float64Neg, s[0]->arch_opcode()); 3109 EXPECT_EQ(kArm64Float64Neg, s[0]->arch_opcode());
3110 ASSERT_EQ(1U, s[0]->InputCount()); 3110 ASSERT_EQ(1U, s[0]->InputCount());
3111 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); 3111 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
3112 ASSERT_EQ(1U, s[0]->OutputCount()); 3112 ASSERT_EQ(1U, s[0]->OutputCount());
3113 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); 3113 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output()));
3114 } 3114 }
3115 3115
3116
3117 TEST_F(InstructionSelectorTest, Float32Max) {
3118 StreamBuilder m(this, kMachFloat32, kMachFloat32, kMachFloat32);
3119 Node* const p0 = m.Parameter(0);
3120 Node* const p1 = m.Parameter(1);
3121 Node* const n = m.Float32Max(p0, p1);
3122 m.Return(n);
3123 Stream s = m.Build();
3124 // Float32Max is `(b < a) ? a : b`.
3125 ASSERT_EQ(1U, s.size());
3126 EXPECT_EQ(kArm64Float32TernaryMax, s[0]->arch_opcode());
3127 ASSERT_EQ(2U, s[0]->InputCount());
3128 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
3129 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1)));
3130 ASSERT_EQ(1U, s[0]->OutputCount());
3131 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output()));
3132 }
3133
3134
3135 TEST_F(InstructionSelectorTest, Float32Min) {
3136 StreamBuilder m(this, kMachFloat32, kMachFloat32, kMachFloat32);
3137 Node* const p0 = m.Parameter(0);
3138 Node* const p1 = m.Parameter(1);
3139 Node* const n = m.Float32Min(p0, p1);
3140 m.Return(n);
3141 Stream s = m.Build();
3142 // Float32Min is `(a < b) ? a : b`.
3143 ASSERT_EQ(1U, s.size());
3144 EXPECT_EQ(kArm64Float32TernaryMin, s[0]->arch_opcode());
3145 ASSERT_EQ(2U, s[0]->InputCount());
3146 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
3147 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1)));
3148 ASSERT_EQ(1U, s[0]->OutputCount());
3149 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output()));
3150 }
3151
3152
3153 TEST_F(InstructionSelectorTest, Float64Max) {
3154 StreamBuilder m(this, kMachFloat64, kMachFloat64, kMachFloat64);
3155 Node* const p0 = m.Parameter(0);
3156 Node* const p1 = m.Parameter(1);
3157 Node* const n = m.Float64Max(p0, p1);
3158 m.Return(n);
3159 Stream s = m.Build();
3160 // Float64Max is `(b < a) ? a : b`.
3161 ASSERT_EQ(1U, s.size());
3162 EXPECT_EQ(kArm64Float64TernaryMax, s[0]->arch_opcode());
3163 ASSERT_EQ(2U, s[0]->InputCount());
3164 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
3165 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1)));
3166 ASSERT_EQ(1U, s[0]->OutputCount());
3167 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output()));
3168 }
3169
3170
3171 TEST_F(InstructionSelectorTest, Float64Min) {
3172 StreamBuilder m(this, kMachFloat64, kMachFloat64, kMachFloat64);
3173 Node* const p0 = m.Parameter(0);
3174 Node* const p1 = m.Parameter(1);
3175 Node* const n = m.Float64Min(p0, p1);
3176 m.Return(n);
3177 Stream s = m.Build();
3178 // Float64Min is `(a < b) ? a : b`.
3179 ASSERT_EQ(1U, s.size());
3180 EXPECT_EQ(kArm64Float64TernaryMin, s[0]->arch_opcode());
3181 ASSERT_EQ(2U, s[0]->InputCount());
3182 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
3183 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1)));
3184 ASSERT_EQ(1U, s[0]->OutputCount());
3185 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output()));
3186 }
3187
3116 } // namespace compiler 3188 } // namespace compiler
3117 } // namespace internal 3189 } // namespace internal
3118 } // namespace v8 3190 } // namespace v8
OLDNEW
« src/compiler/arm64/instruction-codes-arm64.h ('K') | « src/compiler/raw-machine-assembler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698