Index: test/unittests/compiler/arm64/instruction-selector-arm64-unittest.cc |
diff --git a/test/unittests/compiler/arm64/instruction-selector-arm64-unittest.cc b/test/unittests/compiler/arm64/instruction-selector-arm64-unittest.cc |
index 4e53c7ada9cc08266c200c74be2731ade813f320..7e67b31616292c8287e86d7b5ae15dbb87d1ac88 100644 |
--- a/test/unittests/compiler/arm64/instruction-selector-arm64-unittest.cc |
+++ b/test/unittests/compiler/arm64/instruction-selector-arm64-unittest.cc |
@@ -2237,6 +2237,190 @@ TEST_F(InstructionSelectorTest, Word64EqualWithZero) { |
} |
+TEST_F(InstructionSelectorTest, Word32EqualWithWord32Shift) { |
+ TRACED_FOREACH(Shift, shift, kShiftInstructions) { |
+ // Skip non 32-bit shifts or ror operations. |
+ if (shift.mi.machine_type != kMachInt32 || |
+ shift.mi.arch_opcode == kArm64Ror32) { |
+ continue; |
+ } |
+ |
+ TRACED_FORRANGE(int32_t, imm, -32, 63) { |
+ StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
+ Node* const p0 = m.Parameter(0); |
+ Node* const p1 = m.Parameter(1); |
+ Node* r = (m.*shift.mi.constructor)(p1, m.Int32Constant(imm)); |
+ m.Return(m.Word32Equal(p0, r)); |
+ Stream s = m.Build(); |
+ ASSERT_EQ(1U, s.size()); |
+ EXPECT_EQ(kArm64Cmp32, s[0]->arch_opcode()); |
+ EXPECT_EQ(shift.mode, s[0]->addressing_mode()); |
+ ASSERT_EQ(3U, s[0]->InputCount()); |
+ EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
+ EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1))); |
+ EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); |
+ ASSERT_EQ(1U, s[0]->OutputCount()); |
+ } |
+ TRACED_FORRANGE(int32_t, imm, -32, 63) { |
+ StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
+ Node* const p0 = m.Parameter(0); |
+ Node* const p1 = m.Parameter(1); |
+ Node* r = (m.*shift.mi.constructor)(p1, m.Int32Constant(imm)); |
+ m.Return(m.Word32Equal(r, p0)); |
+ Stream s = m.Build(); |
+ ASSERT_EQ(1U, s.size()); |
+ EXPECT_EQ(kArm64Cmp32, s[0]->arch_opcode()); |
+ EXPECT_EQ(shift.mode, s[0]->addressing_mode()); |
+ ASSERT_EQ(3U, s[0]->InputCount()); |
+ EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
+ EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1))); |
+ EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); |
+ ASSERT_EQ(1U, s[0]->OutputCount()); |
+ } |
+ } |
+} |
+ |
+ |
+TEST_F(InstructionSelectorTest, Word32EqualWithUnsignedExtendByte) { |
+ { |
+ StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
+ Node* const p0 = m.Parameter(0); |
+ Node* const p1 = m.Parameter(1); |
+ Node* r = m.Word32And(p1, m.Int32Constant(0xff)); |
+ m.Return(m.Word32Equal(p0, r)); |
+ Stream s = m.Build(); |
+ ASSERT_EQ(1U, s.size()); |
+ EXPECT_EQ(kArm64Cmp32, s[0]->arch_opcode()); |
+ EXPECT_EQ(kMode_Operand2_R_UXTB, s[0]->addressing_mode()); |
+ ASSERT_EQ(2U, s[0]->InputCount()); |
+ EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
+ EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1))); |
+ ASSERT_EQ(1U, s[0]->OutputCount()); |
+ } |
+ { |
+ StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
+ Node* const p0 = m.Parameter(0); |
+ Node* const p1 = m.Parameter(1); |
+ Node* r = m.Word32And(p1, m.Int32Constant(0xff)); |
+ m.Return(m.Word32Equal(r, p0)); |
+ Stream s = m.Build(); |
+ ASSERT_EQ(1U, s.size()); |
+ EXPECT_EQ(kArm64Cmp32, s[0]->arch_opcode()); |
+ EXPECT_EQ(kMode_Operand2_R_UXTB, s[0]->addressing_mode()); |
+ ASSERT_EQ(2U, s[0]->InputCount()); |
+ EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
+ EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1))); |
+ ASSERT_EQ(1U, s[0]->OutputCount()); |
+ } |
+} |
+ |
+ |
+TEST_F(InstructionSelectorTest, Word32EqualWithUnsignedExtendHalfword) { |
+ { |
+ StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
+ Node* const p0 = m.Parameter(0); |
+ Node* const p1 = m.Parameter(1); |
+ Node* r = m.Word32And(p1, m.Int32Constant(0xffff)); |
+ m.Return(m.Word32Equal(p0, r)); |
+ Stream s = m.Build(); |
+ ASSERT_EQ(1U, s.size()); |
+ EXPECT_EQ(kArm64Cmp32, s[0]->arch_opcode()); |
+ EXPECT_EQ(kMode_Operand2_R_UXTH, s[0]->addressing_mode()); |
+ ASSERT_EQ(2U, s[0]->InputCount()); |
+ EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
+ EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1))); |
+ ASSERT_EQ(1U, s[0]->OutputCount()); |
+ } |
+ { |
+ StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
+ Node* const p0 = m.Parameter(0); |
+ Node* const p1 = m.Parameter(1); |
+ Node* r = m.Word32And(p1, m.Int32Constant(0xffff)); |
+ m.Return(m.Word32Equal(r, p0)); |
+ Stream s = m.Build(); |
+ ASSERT_EQ(1U, s.size()); |
+ EXPECT_EQ(kArm64Cmp32, s[0]->arch_opcode()); |
+ EXPECT_EQ(kMode_Operand2_R_UXTH, s[0]->addressing_mode()); |
+ ASSERT_EQ(2U, s[0]->InputCount()); |
+ EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
+ EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1))); |
+ ASSERT_EQ(1U, s[0]->OutputCount()); |
+ } |
+} |
+ |
+ |
+TEST_F(InstructionSelectorTest, Word32EqualWithSignedExtendByte) { |
+ { |
+ StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
+ Node* const p0 = m.Parameter(0); |
+ Node* const p1 = m.Parameter(1); |
+ Node* r = |
+ m.Word32Sar(m.Word32Shl(p1, m.Int32Constant(24)), m.Int32Constant(24)); |
+ m.Return(m.Word32Equal(p0, r)); |
+ Stream s = m.Build(); |
+ ASSERT_EQ(1U, s.size()); |
+ EXPECT_EQ(kArm64Cmp32, s[0]->arch_opcode()); |
+ EXPECT_EQ(kMode_Operand2_R_SXTB, s[0]->addressing_mode()); |
+ ASSERT_EQ(2U, s[0]->InputCount()); |
+ EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
+ EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1))); |
+ ASSERT_EQ(1U, s[0]->OutputCount()); |
+ } |
+ { |
+ StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
+ Node* const p0 = m.Parameter(0); |
+ Node* const p1 = m.Parameter(1); |
+ Node* r = |
+ m.Word32Sar(m.Word32Shl(p1, m.Int32Constant(24)), m.Int32Constant(24)); |
+ m.Return(m.Word32Equal(r, p0)); |
+ Stream s = m.Build(); |
+ ASSERT_EQ(1U, s.size()); |
+ EXPECT_EQ(kArm64Cmp32, s[0]->arch_opcode()); |
+ EXPECT_EQ(kMode_Operand2_R_SXTB, s[0]->addressing_mode()); |
+ ASSERT_EQ(2U, s[0]->InputCount()); |
+ EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
+ EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1))); |
+ ASSERT_EQ(1U, s[0]->OutputCount()); |
+ } |
+} |
+ |
+ |
+TEST_F(InstructionSelectorTest, Word32EqualWithSignedExtendHalfword) { |
+ { |
+ StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
+ Node* const p0 = m.Parameter(0); |
+ Node* const p1 = m.Parameter(1); |
+ Node* r = |
+ m.Word32Sar(m.Word32Shl(p1, m.Int32Constant(16)), m.Int32Constant(16)); |
+ m.Return(m.Word32Equal(p0, r)); |
+ Stream s = m.Build(); |
+ ASSERT_EQ(1U, s.size()); |
+ EXPECT_EQ(kArm64Cmp32, s[0]->arch_opcode()); |
+ EXPECT_EQ(kMode_Operand2_R_SXTH, s[0]->addressing_mode()); |
+ ASSERT_EQ(2U, s[0]->InputCount()); |
+ EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
+ EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1))); |
+ ASSERT_EQ(1U, s[0]->OutputCount()); |
+ } |
+ { |
+ StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
+ Node* const p0 = m.Parameter(0); |
+ Node* const p1 = m.Parameter(1); |
+ Node* r = |
+ m.Word32Sar(m.Word32Shl(p1, m.Int32Constant(16)), m.Int32Constant(16)); |
+ m.Return(m.Word32Equal(r, p0)); |
+ Stream s = m.Build(); |
+ ASSERT_EQ(1U, s.size()); |
+ EXPECT_EQ(kArm64Cmp32, s[0]->arch_opcode()); |
+ EXPECT_EQ(kMode_Operand2_R_SXTH, s[0]->addressing_mode()); |
+ ASSERT_EQ(2U, s[0]->InputCount()); |
+ EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
+ EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1))); |
+ ASSERT_EQ(1U, s[0]->OutputCount()); |
+ } |
+} |
+ |
+ |
// ----------------------------------------------------------------------------- |
// Miscellaneous |