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

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

Issue 1404093003: [turbofan] Negate with shifted input for ARM64 (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/code-generator-impl.h ('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 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 ASSERT_EQ(2U, s[0]->InputCount()); 576 ASSERT_EQ(2U, s[0]->InputCount());
577 EXPECT_TRUE(s[0]->InputAt(1)->IsImmediate()); 577 EXPECT_TRUE(s[0]->InputAt(1)->IsImmediate());
578 EXPECT_EQ(imm, s.ToInt64(s[0]->InputAt(1))); 578 EXPECT_EQ(imm, s.ToInt64(s[0]->InputAt(1)));
579 EXPECT_EQ(1U, s[0]->OutputCount()); 579 EXPECT_EQ(1U, s[0]->OutputCount());
580 } 580 }
581 } 581 }
582 } 582 }
583 583
584 584
585 TEST_F(InstructionSelectorTest, SubZeroOnLeft) { 585 TEST_F(InstructionSelectorTest, SubZeroOnLeft) {
586 // Subtraction with zero on the left maps to Neg.
587 { 586 {
588 // 32-bit subtract. 587 // 32-bit subtract.
589 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); 588 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
590 m.Return(m.Int32Sub(m.Int32Constant(0), m.Parameter(0))); 589 m.Return(m.Int32Sub(m.Int32Constant(0), m.Parameter(0)));
591 Stream s = m.Build(); 590 Stream s = m.Build();
592 591
593 ASSERT_EQ(1U, s.size()); 592 ASSERT_EQ(1U, s.size());
594 EXPECT_EQ(kArm64Neg32, s[0]->arch_opcode()); 593 EXPECT_EQ(kArm64Sub32, s[0]->arch_opcode());
595 EXPECT_EQ(1U, s[0]->InputCount()); 594 ASSERT_EQ(2U, s[0]->InputCount());
595 EXPECT_TRUE(s[0]->InputAt(0)->IsImmediate());
596 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(0)));
596 EXPECT_EQ(1U, s[0]->OutputCount()); 597 EXPECT_EQ(1U, s[0]->OutputCount());
597 } 598 }
598 { 599 {
599 // 64-bit subtract. 600 // 64-bit subtract.
600 StreamBuilder m(this, kMachInt64, kMachInt64, kMachInt64); 601 StreamBuilder m(this, kMachInt64, kMachInt64, kMachInt64);
601 m.Return(m.Int64Sub(m.Int64Constant(0), m.Parameter(0))); 602 m.Return(m.Int64Sub(m.Int64Constant(0), m.Parameter(0)));
602 Stream s = m.Build(); 603 Stream s = m.Build();
603 604
604 ASSERT_EQ(1U, s.size()); 605 ASSERT_EQ(1U, s.size());
605 EXPECT_EQ(kArm64Neg, s[0]->arch_opcode()); 606 EXPECT_EQ(kArm64Sub, s[0]->arch_opcode());
606 EXPECT_EQ(1U, s[0]->InputCount()); 607 ASSERT_EQ(2U, s[0]->InputCount());
608 EXPECT_TRUE(s[0]->InputAt(0)->IsImmediate());
609 EXPECT_EQ(0, s.ToInt64(s[0]->InputAt(0)));
607 EXPECT_EQ(1U, s[0]->OutputCount()); 610 EXPECT_EQ(1U, s[0]->OutputCount());
608 } 611 }
609 } 612 }
610 613
611 614
615 TEST_F(InstructionSelectorTest, SubZeroOnLeftWithShift) {
616 TRACED_FOREACH(Shift, shift, kShiftInstructions) {
617 {
618 // Test 32-bit operations. Ignore ROR shifts, as subtract does not
619 // support them.
620 if ((shift.mi.machine_type != kMachInt32) ||
621 (shift.mi.arch_opcode == kArm64Ror32) ||
622 (shift.mi.arch_opcode == kArm64Ror))
623 continue;
624
625 TRACED_FORRANGE(int, imm, -32, 63) {
626 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
627 m.Return(m.Int32Sub(
628 m.Int32Constant(0),
629 (m.*shift.mi.constructor)(m.Parameter(1), m.Int32Constant(imm))));
630 Stream s = m.Build();
631
632 ASSERT_EQ(1U, s.size());
633 EXPECT_EQ(kArm64Sub32, s[0]->arch_opcode());
634 ASSERT_EQ(3U, s[0]->InputCount());
635 EXPECT_TRUE(s[0]->InputAt(0)->IsImmediate());
636 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(0)));
637 EXPECT_EQ(shift.mode, s[0]->addressing_mode());
638 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2)));
639 EXPECT_EQ(1U, s[0]->OutputCount());
640 }
641 }
642 {
643 // Test 64-bit operations. Ignore ROR shifts, as subtract does not
644 // support them.
645 if ((shift.mi.machine_type != kMachInt64) ||
646 (shift.mi.arch_opcode == kArm64Ror32) ||
647 (shift.mi.arch_opcode == kArm64Ror))
648 continue;
649
650 TRACED_FORRANGE(int, imm, -32, 127) {
651 StreamBuilder m(this, kMachInt64, kMachInt64, kMachInt64);
652 m.Return(m.Int64Sub(
653 m.Int64Constant(0),
654 (m.*shift.mi.constructor)(m.Parameter(1), m.Int64Constant(imm))));
655 Stream s = m.Build();
656
657 ASSERT_EQ(1U, s.size());
658 EXPECT_EQ(kArm64Sub, s[0]->arch_opcode());
659 ASSERT_EQ(3U, s[0]->InputCount());
660 EXPECT_TRUE(s[0]->InputAt(0)->IsImmediate());
661 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(0)));
662 EXPECT_EQ(shift.mode, s[0]->addressing_mode());
663 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2)));
664 EXPECT_EQ(1U, s[0]->OutputCount());
665 }
666 }
667 }
668 }
669
670
612 TEST_F(InstructionSelectorTest, AddNegImmediateOnLeft) { 671 TEST_F(InstructionSelectorTest, AddNegImmediateOnLeft) {
613 { 672 {
614 // 32-bit add. 673 // 32-bit add.
615 TRACED_FOREACH(int32_t, imm, kAddSubImmediates) { 674 TRACED_FOREACH(int32_t, imm, kAddSubImmediates) {
616 if (imm == 0) continue; 675 if (imm == 0) continue;
617 StreamBuilder m(this, kMachInt32, kMachInt32); 676 StreamBuilder m(this, kMachInt32, kMachInt32);
618 m.Return(m.Int32Add(m.Int32Constant(-imm), m.Parameter(0))); 677 m.Return(m.Int32Add(m.Int32Constant(-imm), m.Parameter(0)));
619 Stream s = m.Build(); 678 Stream s = m.Build();
620 679
621 ASSERT_EQ(1U, s.size()); 680 ASSERT_EQ(1U, s.size());
(...skipping 2428 matching lines...) Expand 10 before | Expand all | Expand 10 after
3050 EXPECT_EQ(kArm64Float64Neg, s[0]->arch_opcode()); 3109 EXPECT_EQ(kArm64Float64Neg, s[0]->arch_opcode());
3051 ASSERT_EQ(1U, s[0]->InputCount()); 3110 ASSERT_EQ(1U, s[0]->InputCount());
3052 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); 3111 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
3053 ASSERT_EQ(1U, s[0]->OutputCount()); 3112 ASSERT_EQ(1U, s[0]->OutputCount());
3054 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); 3113 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output()));
3055 } 3114 }
3056 3115
3057 } // namespace compiler 3116 } // namespace compiler
3058 } // namespace internal 3117 } // namespace internal
3059 } // namespace v8 3118 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/code-generator-impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698