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

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

Issue 1218103005: [turbofan] Support cmp with shift/extend on ARM64. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 5 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/arm64/instruction-selector-arm64.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 2219 matching lines...) Expand 10 before | Expand all | Expand 10 after
2230 EXPECT_EQ(kArm64Tst, s[0]->arch_opcode()); 2230 EXPECT_EQ(kArm64Tst, s[0]->arch_opcode());
2231 ASSERT_EQ(2U, s[0]->InputCount()); 2231 ASSERT_EQ(2U, s[0]->InputCount());
2232 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[0]->InputAt(1))); 2232 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[0]->InputAt(1)));
2233 EXPECT_EQ(1U, s[0]->OutputCount()); 2233 EXPECT_EQ(1U, s[0]->OutputCount());
2234 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); 2234 EXPECT_EQ(kFlags_set, s[0]->flags_mode());
2235 EXPECT_EQ(kEqual, s[0]->flags_condition()); 2235 EXPECT_EQ(kEqual, s[0]->flags_condition());
2236 } 2236 }
2237 } 2237 }
2238 2238
2239 2239
2240 TEST_F(InstructionSelectorTest, Word32EqualWithWord32Shift) {
2241 TRACED_FOREACH(Shift, shift, kShiftInstructions) {
2242 // Skip non 32-bit shifts or ror operations.
2243 if (shift.mi.machine_type != kMachInt32 ||
2244 shift.mi.arch_opcode == kArm64Ror32) {
2245 continue;
2246 }
2247
2248 TRACED_FORRANGE(int32_t, imm, -32, 63) {
2249 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
2250 Node* const p0 = m.Parameter(0);
2251 Node* const p1 = m.Parameter(1);
2252 Node* r = (m.*shift.mi.constructor)(p1, m.Int32Constant(imm));
2253 m.Return(m.Word32Equal(p0, r));
2254 Stream s = m.Build();
2255 ASSERT_EQ(1U, s.size());
2256 EXPECT_EQ(kArm64Cmp32, s[0]->arch_opcode());
2257 EXPECT_EQ(shift.mode, s[0]->addressing_mode());
2258 ASSERT_EQ(3U, s[0]->InputCount());
2259 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
2260 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1)));
2261 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2)));
2262 ASSERT_EQ(1U, s[0]->OutputCount());
2263 }
2264 TRACED_FORRANGE(int32_t, imm, -32, 63) {
2265 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
2266 Node* const p0 = m.Parameter(0);
2267 Node* const p1 = m.Parameter(1);
2268 Node* r = (m.*shift.mi.constructor)(p1, m.Int32Constant(imm));
2269 m.Return(m.Word32Equal(r, p0));
2270 Stream s = m.Build();
2271 ASSERT_EQ(1U, s.size());
2272 EXPECT_EQ(kArm64Cmp32, s[0]->arch_opcode());
2273 EXPECT_EQ(shift.mode, s[0]->addressing_mode());
2274 ASSERT_EQ(3U, s[0]->InputCount());
2275 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
2276 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1)));
2277 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2)));
2278 ASSERT_EQ(1U, s[0]->OutputCount());
2279 }
2280 }
2281 }
2282
2283
2284 TEST_F(InstructionSelectorTest, Word32EqualWithUnsignedExtendByte) {
2285 {
2286 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
2287 Node* const p0 = m.Parameter(0);
2288 Node* const p1 = m.Parameter(1);
2289 Node* r = m.Word32And(p1, m.Int32Constant(0xff));
2290 m.Return(m.Word32Equal(p0, r));
2291 Stream s = m.Build();
2292 ASSERT_EQ(1U, s.size());
2293 EXPECT_EQ(kArm64Cmp32, s[0]->arch_opcode());
2294 EXPECT_EQ(kMode_Operand2_R_UXTB, s[0]->addressing_mode());
2295 ASSERT_EQ(2U, s[0]->InputCount());
2296 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
2297 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1)));
2298 ASSERT_EQ(1U, s[0]->OutputCount());
2299 }
2300 {
2301 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
2302 Node* const p0 = m.Parameter(0);
2303 Node* const p1 = m.Parameter(1);
2304 Node* r = m.Word32And(p1, m.Int32Constant(0xff));
2305 m.Return(m.Word32Equal(r, p0));
2306 Stream s = m.Build();
2307 ASSERT_EQ(1U, s.size());
2308 EXPECT_EQ(kArm64Cmp32, s[0]->arch_opcode());
2309 EXPECT_EQ(kMode_Operand2_R_UXTB, s[0]->addressing_mode());
2310 ASSERT_EQ(2U, s[0]->InputCount());
2311 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
2312 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1)));
2313 ASSERT_EQ(1U, s[0]->OutputCount());
2314 }
2315 }
2316
2317
2318 TEST_F(InstructionSelectorTest, Word32EqualWithUnsignedExtendHalfword) {
2319 {
2320 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
2321 Node* const p0 = m.Parameter(0);
2322 Node* const p1 = m.Parameter(1);
2323 Node* r = m.Word32And(p1, m.Int32Constant(0xffff));
2324 m.Return(m.Word32Equal(p0, r));
2325 Stream s = m.Build();
2326 ASSERT_EQ(1U, s.size());
2327 EXPECT_EQ(kArm64Cmp32, s[0]->arch_opcode());
2328 EXPECT_EQ(kMode_Operand2_R_UXTH, s[0]->addressing_mode());
2329 ASSERT_EQ(2U, s[0]->InputCount());
2330 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
2331 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1)));
2332 ASSERT_EQ(1U, s[0]->OutputCount());
2333 }
2334 {
2335 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
2336 Node* const p0 = m.Parameter(0);
2337 Node* const p1 = m.Parameter(1);
2338 Node* r = m.Word32And(p1, m.Int32Constant(0xffff));
2339 m.Return(m.Word32Equal(r, p0));
2340 Stream s = m.Build();
2341 ASSERT_EQ(1U, s.size());
2342 EXPECT_EQ(kArm64Cmp32, s[0]->arch_opcode());
2343 EXPECT_EQ(kMode_Operand2_R_UXTH, s[0]->addressing_mode());
2344 ASSERT_EQ(2U, s[0]->InputCount());
2345 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
2346 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1)));
2347 ASSERT_EQ(1U, s[0]->OutputCount());
2348 }
2349 }
2350
2351
2352 TEST_F(InstructionSelectorTest, Word32EqualWithSignedExtendByte) {
2353 {
2354 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
2355 Node* const p0 = m.Parameter(0);
2356 Node* const p1 = m.Parameter(1);
2357 Node* r =
2358 m.Word32Sar(m.Word32Shl(p1, m.Int32Constant(24)), m.Int32Constant(24));
2359 m.Return(m.Word32Equal(p0, r));
2360 Stream s = m.Build();
2361 ASSERT_EQ(1U, s.size());
2362 EXPECT_EQ(kArm64Cmp32, s[0]->arch_opcode());
2363 EXPECT_EQ(kMode_Operand2_R_SXTB, s[0]->addressing_mode());
2364 ASSERT_EQ(2U, s[0]->InputCount());
2365 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
2366 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1)));
2367 ASSERT_EQ(1U, s[0]->OutputCount());
2368 }
2369 {
2370 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
2371 Node* const p0 = m.Parameter(0);
2372 Node* const p1 = m.Parameter(1);
2373 Node* r =
2374 m.Word32Sar(m.Word32Shl(p1, m.Int32Constant(24)), m.Int32Constant(24));
2375 m.Return(m.Word32Equal(r, p0));
2376 Stream s = m.Build();
2377 ASSERT_EQ(1U, s.size());
2378 EXPECT_EQ(kArm64Cmp32, s[0]->arch_opcode());
2379 EXPECT_EQ(kMode_Operand2_R_SXTB, s[0]->addressing_mode());
2380 ASSERT_EQ(2U, s[0]->InputCount());
2381 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
2382 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1)));
2383 ASSERT_EQ(1U, s[0]->OutputCount());
2384 }
2385 }
2386
2387
2388 TEST_F(InstructionSelectorTest, Word32EqualWithSignedExtendHalfword) {
2389 {
2390 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
2391 Node* const p0 = m.Parameter(0);
2392 Node* const p1 = m.Parameter(1);
2393 Node* r =
2394 m.Word32Sar(m.Word32Shl(p1, m.Int32Constant(16)), m.Int32Constant(16));
2395 m.Return(m.Word32Equal(p0, r));
2396 Stream s = m.Build();
2397 ASSERT_EQ(1U, s.size());
2398 EXPECT_EQ(kArm64Cmp32, s[0]->arch_opcode());
2399 EXPECT_EQ(kMode_Operand2_R_SXTH, s[0]->addressing_mode());
2400 ASSERT_EQ(2U, s[0]->InputCount());
2401 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
2402 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1)));
2403 ASSERT_EQ(1U, s[0]->OutputCount());
2404 }
2405 {
2406 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
2407 Node* const p0 = m.Parameter(0);
2408 Node* const p1 = m.Parameter(1);
2409 Node* r =
2410 m.Word32Sar(m.Word32Shl(p1, m.Int32Constant(16)), m.Int32Constant(16));
2411 m.Return(m.Word32Equal(r, p0));
2412 Stream s = m.Build();
2413 ASSERT_EQ(1U, s.size());
2414 EXPECT_EQ(kArm64Cmp32, s[0]->arch_opcode());
2415 EXPECT_EQ(kMode_Operand2_R_SXTH, s[0]->addressing_mode());
2416 ASSERT_EQ(2U, s[0]->InputCount());
2417 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
2418 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1)));
2419 ASSERT_EQ(1U, s[0]->OutputCount());
2420 }
2421 }
2422
2423
2240 // ----------------------------------------------------------------------------- 2424 // -----------------------------------------------------------------------------
2241 // Miscellaneous 2425 // Miscellaneous
2242 2426
2243 2427
2244 static const MachInst2 kLogicalWithNotRHSs[] = { 2428 static const MachInst2 kLogicalWithNotRHSs[] = {
2245 {&RawMachineAssembler::Word32And, "Word32And", kArm64Bic32, kMachInt32}, 2429 {&RawMachineAssembler::Word32And, "Word32And", kArm64Bic32, kMachInt32},
2246 {&RawMachineAssembler::Word64And, "Word64And", kArm64Bic, kMachInt64}, 2430 {&RawMachineAssembler::Word64And, "Word64And", kArm64Bic, kMachInt64},
2247 {&RawMachineAssembler::Word32Or, "Word32Or", kArm64Orn32, kMachInt32}, 2431 {&RawMachineAssembler::Word32Or, "Word32Or", kArm64Orn32, kMachInt32},
2248 {&RawMachineAssembler::Word64Or, "Word64Or", kArm64Orn, kMachInt64}, 2432 {&RawMachineAssembler::Word64Or, "Word64Or", kArm64Orn, kMachInt64},
2249 {&RawMachineAssembler::Word32Xor, "Word32Xor", kArm64Eon32, kMachInt32}, 2433 {&RawMachineAssembler::Word32Xor, "Word32Xor", kArm64Eon32, kMachInt32},
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
2813 EXPECT_EQ(kArm64Float64Neg, s[0]->arch_opcode()); 2997 EXPECT_EQ(kArm64Float64Neg, s[0]->arch_opcode());
2814 ASSERT_EQ(1U, s[0]->InputCount()); 2998 ASSERT_EQ(1U, s[0]->InputCount());
2815 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); 2999 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
2816 ASSERT_EQ(1U, s[0]->OutputCount()); 3000 ASSERT_EQ(1U, s[0]->OutputCount());
2817 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); 3001 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output()));
2818 } 3002 }
2819 3003
2820 } // namespace compiler 3004 } // namespace compiler
2821 } // namespace internal 3005 } // namespace internal
2822 } // namespace v8 3006 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/arm64/instruction-selector-arm64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698