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

Unified Diff: src/compiler/x64/instruction-selector-x64-unittest.cc

Issue 591343002: [turbofan] IA: support better left operand for commutative binops (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comments Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/x64/instruction-selector-x64.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/x64/instruction-selector-x64-unittest.cc
diff --git a/src/compiler/x64/instruction-selector-x64-unittest.cc b/src/compiler/x64/instruction-selector-x64-unittest.cc
index 22f0bce6a089033f0a1c3ec8c6cdddb1887aec15..814c2592da9d0dcf522488dabea8c3f5956ad19b 100644
--- a/src/compiler/x64/instruction-selector-x64-unittest.cc
+++ b/src/compiler/x64/instruction-selector-x64-unittest.cc
@@ -40,6 +40,39 @@ TEST_F(InstructionSelectorTest, TruncateInt64ToInt32WithParameter) {
// -----------------------------------------------------------------------------
+// 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(kX64Add32, 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(kX64Imul32, 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 {
« no previous file with comments | « src/compiler/x64/instruction-selector-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698