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

Unified Diff: test/unittests/compiler/node-matchers-unittest.cc

Issue 2137323003: [turbofan] Support subtraction displacements in BaseWithIndexAndDisplacementMatcher (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Review feedback Created 4 years, 5 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: test/unittests/compiler/node-matchers-unittest.cc
diff --git a/test/unittests/compiler/node-matchers-unittest.cc b/test/unittests/compiler/node-matchers-unittest.cc
index f0cc407445272917cab54076d77355b41176f97d..45d7427494e00948543fc529c289539014a9f07f 100644
--- a/test/unittests/compiler/node-matchers-unittest.cc
+++ b/test/unittests/compiler/node-matchers-unittest.cc
@@ -30,13 +30,15 @@ class NodeMatcherTest : public GraphTest {
namespace {
template <class Matcher>
-void CheckBaseWithIndexAndDisplacement(Matcher* matcher, Node* index, int scale,
- Node* base, Node* displacement) {
+void CheckBaseWithIndexAndDisplacement(
+ Matcher* matcher, Node* index, int scale, Node* base, Node* displacement,
+ DisplacementMode displacement_mode = kPositiveDisplacement) {
EXPECT_TRUE(matcher->matches());
EXPECT_EQ(index, matcher->index());
EXPECT_EQ(scale, matcher->scale());
EXPECT_EQ(base, matcher->base());
EXPECT_EQ(displacement, matcher->displacement());
+ EXPECT_EQ(displacement_mode, matcher->displacement_mode());
}
} // namespace
@@ -90,6 +92,9 @@ TEST_F(NodeMatcherTest, ScaledWithOffset32Matcher) {
const Operator* a_op = machine()->Int32Add();
USE(a_op);
+ const Operator* sub_op = machine()->Int32Sub();
+ USE(sub_op);
+
const Operator* m_op = machine()->Int32Mul();
Node* m1 = graph()->NewNode(m_op, p1, d1);
Node* m2 = graph()->NewNode(m_op, p1, d2);
@@ -354,7 +359,25 @@ TEST_F(NodeMatcherTest, ScaledWithOffset32Matcher) {
graph()->NewNode(a_op, s3, graph()->NewNode(a_op, b0, d15)));
CheckBaseWithIndexAndDisplacement(&match43, p1, 3, b0, d15);
- // Check that scales that require using the base address work dorrectly.
+ // S3 + (B0 - D15) -> [p1, 2, b0, d15, true]
+ s3 = graph()->NewNode(s_op, p1, d3);
+ BaseWithIndexAndDisplacement32Matcher match44(
+ graph()->NewNode(a_op, s3, graph()->NewNode(sub_op, b0, d15)));
+ CheckBaseWithIndexAndDisplacement(&match44, p1, 3, b0, d15,
+ kNegativeDisplacement);
+
+ // B0 + (B1 - D15) -> [p1, 2, b0, d15, true]
+ BaseWithIndexAndDisplacement32Matcher match45(
+ graph()->NewNode(a_op, b0, graph()->NewNode(sub_op, b1, d15)));
+ CheckBaseWithIndexAndDisplacement(&match45, b1, 0, b0, d15,
+ kNegativeDisplacement);
+
+ // (B0 - D15) + S3 -> [p1, 2, b0, d15, true]
+ s3 = graph()->NewNode(s_op, p1, d3);
+ BaseWithIndexAndDisplacement32Matcher match46(
+ graph()->NewNode(a_op, graph()->NewNode(sub_op, b0, d15), s3));
+ CheckBaseWithIndexAndDisplacement(&match46, p1, 3, b0, d15,
+ kNegativeDisplacement);
}
@@ -409,6 +432,9 @@ TEST_F(NodeMatcherTest, ScaledWithOffset64Matcher) {
const Operator* a_op = machine()->Int64Add();
USE(a_op);
+ const Operator* sub_op = machine()->Int64Sub();
+ USE(sub_op);
+
const Operator* m_op = machine()->Int64Mul();
Node* m1 = graph()->NewNode(m_op, p1, d1);
Node* m2 = graph()->NewNode(m_op, p1, d2);
@@ -726,8 +752,27 @@ TEST_F(NodeMatcherTest, ScaledWithOffset64Matcher) {
BaseWithIndexAndDisplacement64Matcher match50(
graph()->NewNode(a_op, m3, temp));
CheckBaseWithIndexAndDisplacement(&match50, m3, 0, b0, d15);
-}
+ // S3 + (B0 - D15) -> [p1, 2, b0, d15, true]
+ s3 = graph()->NewNode(s_op, p1, d3);
+ BaseWithIndexAndDisplacement64Matcher match51(
+ graph()->NewNode(a_op, s3, graph()->NewNode(sub_op, b0, d15)));
+ CheckBaseWithIndexAndDisplacement(&match51, p1, 3, b0, d15,
+ kNegativeDisplacement);
+
+ // B0 + (B1 - D15) -> [p1, 2, b0, d15, true]
+ BaseWithIndexAndDisplacement64Matcher match52(
+ graph()->NewNode(a_op, b0, graph()->NewNode(sub_op, b1, d15)));
+ CheckBaseWithIndexAndDisplacement(&match52, b1, 0, b0, d15,
+ kNegativeDisplacement);
+
+ // (B0 - D15) + S3 -> [p1, 2, b0, d15, true]
+ s3 = graph()->NewNode(s_op, p1, d3);
+ BaseWithIndexAndDisplacement64Matcher match53(
+ graph()->NewNode(a_op, graph()->NewNode(sub_op, b0, d15), s3));
+ CheckBaseWithIndexAndDisplacement(&match53, p1, 3, b0, d15,
+ kNegativeDisplacement);
+}
TEST_F(NodeMatcherTest, BranchMatcher_match) {
Node* zero = graph()->NewNode(common()->Int32Constant(0));
« 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