Index: src/compiler/ia32/instruction-selector-ia32-unittest.cc |
diff --git a/src/compiler/ia32/instruction-selector-ia32-unittest.cc b/src/compiler/ia32/instruction-selector-ia32-unittest.cc |
index 60708c1ebe64abff032339100eccd00d49d7e6ee..5c579a91bd2564e655767502177ae4536ec7030e 100644 |
--- a/src/compiler/ia32/instruction-selector-ia32-unittest.cc |
+++ b/src/compiler/ia32/instruction-selector-ia32-unittest.cc |
@@ -75,6 +75,39 @@ TEST_F(InstructionSelectorTest, Int32SubWithImmediate) { |
// ----------------------------------------------------------------------------- |
+// Better left operand for commutative binops |
+ |
+TEST_F(InstructionSelectorTest, BetterLeftOperandTestAddBinop) { |
+ StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
+ Node* param1 = m.Parameter(0); |
+ Node* param2 = m.Parameter(1); |
+ Node* add = m.Int32Add(param1, param2); |
+ m.Return(m.Int32Add(add, param1)); |
+ Stream s = m.Build(); |
+ ASSERT_EQ(2U, s.size()); |
+ EXPECT_EQ(kIA32Add, s[0]->arch_opcode()); |
+ ASSERT_EQ(2U, s[0]->InputCount()); |
+ ASSERT_TRUE(s[0]->InputAt(0)->IsUnallocated()); |
+ EXPECT_EQ(param2->id(), s.ToVreg(s[0]->InputAt(0))); |
+} |
+ |
+ |
+TEST_F(InstructionSelectorTest, BetterLeftOperandTestMulBinop) { |
+ StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
+ Node* param1 = m.Parameter(0); |
+ Node* param2 = m.Parameter(1); |
+ Node* mul = m.Int32Mul(param1, param2); |
+ m.Return(m.Int32Mul(mul, param1)); |
+ Stream s = m.Build(); |
+ ASSERT_EQ(2U, s.size()); |
+ EXPECT_EQ(kIA32Imul, s[0]->arch_opcode()); |
+ ASSERT_EQ(2U, s[0]->InputCount()); |
+ ASSERT_TRUE(s[0]->InputAt(0)->IsUnallocated()); |
+ EXPECT_EQ(param2->id(), s.ToVreg(s[0]->InputAt(0))); |
+} |
+ |
+ |
+// ----------------------------------------------------------------------------- |
// Loads and stores |
namespace { |