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

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

Issue 1410123009: [turbofan] Use cmn on ARM64 for negated rhs cmp (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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
« 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 2515 matching lines...) Expand 10 before | Expand all | Expand 10 after
2526 EXPECT_EQ(kArm64Cmp32, s[0]->arch_opcode()); 2526 EXPECT_EQ(kArm64Cmp32, s[0]->arch_opcode());
2527 ASSERT_EQ(2U, s[0]->InputCount()); 2527 ASSERT_EQ(2U, s[0]->InputCount());
2528 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); 2528 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
2529 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1))); 2529 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1)));
2530 EXPECT_EQ(1U, s[0]->OutputCount()); 2530 EXPECT_EQ(1U, s[0]->OutputCount());
2531 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); 2531 EXPECT_EQ(kFlags_set, s[0]->flags_mode());
2532 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); 2532 EXPECT_EQ(kNotEqual, s[0]->flags_condition());
2533 } 2533 }
2534 } 2534 }
2535 2535
2536 namespace {
2537
2538 struct IntegerCmp {
2539 MachInst2 mi;
2540 FlagsCondition cond;
2541 };
2542
2543
2544 std::ostream& operator<<(std::ostream& os, const IntegerCmp& cmp) {
2545 return os << cmp.mi;
2546 }
2547
2548
2549 // ARM64 32-bit integer comparison instructions.
2550 const IntegerCmp kIntegerCmpInstructions[] = {
2551 {{&RawMachineAssembler::Word32Equal, "Word32Equal", kArm64Cmp32,
2552 kMachInt32},
2553 kEqual},
2554 {{&RawMachineAssembler::Int32LessThan, "Int32LessThan", kArm64Cmp32,
2555 kMachInt32},
2556 kSignedLessThan},
2557 {{&RawMachineAssembler::Int32LessThanOrEqual, "Int32LessThanOrEqual",
2558 kArm64Cmp32, kMachInt32},
2559 kSignedLessThanOrEqual},
2560 {{&RawMachineAssembler::Uint32LessThan, "Uint32LessThan", kArm64Cmp32,
2561 kMachUint32},
2562 kUnsignedLessThan},
2563 {{&RawMachineAssembler::Uint32LessThanOrEqual, "Uint32LessThanOrEqual",
2564 kArm64Cmp32, kMachUint32},
2565 kUnsignedLessThanOrEqual}};
2566
2567 } // namespace
2568
2569
2570 TEST_F(InstructionSelectorTest, Word32CompareNegateWithWord32Shift) {
2571 TRACED_FOREACH(IntegerCmp, cmp, kIntegerCmpInstructions) {
2572 TRACED_FOREACH(Shift, shift, kShiftInstructions) {
2573 // Test 32-bit operations. Ignore ROR shifts, as compare-negate does not
2574 // support them.
2575 if (shift.mi.machine_type != kMachInt32 ||
2576 shift.mi.arch_opcode == kArm64Ror32) {
2577 continue;
2578 }
2579
2580 TRACED_FORRANGE(int32_t, imm, -32, 63) {
2581 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
2582 Node* const p0 = m.Parameter(0);
2583 Node* const p1 = m.Parameter(1);
2584 Node* r = (m.*shift.mi.constructor)(p1, m.Int32Constant(imm));
2585 m.Return(
2586 (m.*cmp.mi.constructor)(p0, m.Int32Sub(m.Int32Constant(0), r)));
2587 Stream s = m.Build();
2588 ASSERT_EQ(1U, s.size());
2589 EXPECT_EQ(kArm64Cmn32, s[0]->arch_opcode());
2590 EXPECT_EQ(3U, s[0]->InputCount());
2591 EXPECT_EQ(shift.mode, s[0]->addressing_mode());
2592 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2)));
2593 EXPECT_EQ(1U, s[0]->OutputCount());
2594 EXPECT_EQ(kFlags_set, s[0]->flags_mode());
2595 EXPECT_EQ(cmp.cond, s[0]->flags_condition());
2596 }
2597 }
2598 }
2599 }
2600
2536 2601
2537 // ----------------------------------------------------------------------------- 2602 // -----------------------------------------------------------------------------
2538 // Miscellaneous 2603 // Miscellaneous
2539 2604
2540 2605
2541 static const MachInst2 kLogicalWithNotRHSs[] = { 2606 static const MachInst2 kLogicalWithNotRHSs[] = {
2542 {&RawMachineAssembler::Word32And, "Word32And", kArm64Bic32, kMachInt32}, 2607 {&RawMachineAssembler::Word32And, "Word32And", kArm64Bic32, kMachInt32},
2543 {&RawMachineAssembler::Word64And, "Word64And", kArm64Bic, kMachInt64}, 2608 {&RawMachineAssembler::Word64And, "Word64And", kArm64Bic, kMachInt64},
2544 {&RawMachineAssembler::Word32Or, "Word32Or", kArm64Orn32, kMachInt32}, 2609 {&RawMachineAssembler::Word32Or, "Word32Or", kArm64Orn32, kMachInt32},
2545 {&RawMachineAssembler::Word64Or, "Word64Or", kArm64Orn, kMachInt64}, 2610 {&RawMachineAssembler::Word64Or, "Word64Or", kArm64Orn, kMachInt64},
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
3182 ASSERT_EQ(2U, s[0]->InputCount()); 3247 ASSERT_EQ(2U, s[0]->InputCount());
3183 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); 3248 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
3184 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1))); 3249 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1)));
3185 ASSERT_EQ(1U, s[0]->OutputCount()); 3250 ASSERT_EQ(1U, s[0]->OutputCount());
3186 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); 3251 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output()));
3187 } 3252 }
3188 3253
3189 } // namespace compiler 3254 } // namespace compiler
3190 } // namespace internal 3255 } // namespace internal
3191 } // namespace v8 3256 } // 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