Chromium Code Reviews

Unified Diff: test/unittests/compiler/int64-lowering-unittest.cc

Issue 1843123002: [wasm] Int64Lowering of Word64Ror and Word64Rol. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
« src/compiler/int64-lowering.cc ('K') | « test/cctest/wasm/test-run-wasm-64.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/int64-lowering-unittest.cc
diff --git a/test/unittests/compiler/int64-lowering-unittest.cc b/test/unittests/compiler/int64-lowering-unittest.cc
index 4e82660d14fc68226fa74b34c8d1c872fe9944a2..14bc22e46fa510a07201abb6ba81311e5571dc9e 100644
--- a/test/unittests/compiler/int64-lowering-unittest.cc
+++ b/test/unittests/compiler/int64-lowering-unittest.cc
@@ -660,6 +660,107 @@ TEST_F(Int64LoweringTest, I64Popcnt) {
IsInt32Constant(0), start(), start()));
}
+TEST_F(Int64LoweringTest, I64Ror) {
+ LowerGraph(graph()->NewNode(machine()->Word64Ror(), Int64Constant(value(0)),
+ Parameter(0)),
+ MachineRepresentation::kWord64, MachineRepresentation::kWord64, 1);
+
+ Matcher<Node*> branch_eqz_matcher =
+ IsBranch(IsWord32Equal(IsWord32And(IsParameter(0), IsInt32Constant(0x1f)),
+ IsInt32Constant(0)),
+ start());
+
+ Matcher<Node*> branch_lt32_matcher = IsBranch(
+ IsInt32LessThan(IsWord32And(IsParameter(0), IsInt32Constant(0x3f)),
+ IsInt32Constant(32)),
+ start());
+
+ Matcher<Node*> low_matcher = IsPhi(
+ MachineRepresentation::kWord32, IsInt32Constant(low_word_value(0)),
+ IsInt32Constant(high_word_value(0)),
+ IsMerge(IsIfTrue(branch_lt32_matcher), IsIfFalse(branch_lt32_matcher)));
+
+ Matcher<Node*> high_matcher = IsPhi(
+ MachineRepresentation::kWord32, IsInt32Constant(high_word_value(0)),
+ IsInt32Constant(low_word_value(0)),
+ IsMerge(IsIfTrue(branch_lt32_matcher), IsIfFalse(branch_lt32_matcher)));
+
+ Matcher<Node*> shift_matcher =
+ IsWord32And(IsParameter(0), IsInt32Constant(0x1f));
+ Matcher<Node*> inv_shift_matcher =
+ IsInt32Sub(IsInt32Constant(32), shift_matcher);
+
+ EXPECT_THAT(
+ graph()->end()->InputAt(1),
+ IsReturn2(IsPhi(MachineRepresentation::kWord32, low_matcher,
+ IsWord32Or(IsWord32Shr(low_matcher, shift_matcher),
+ IsWord32Shl(high_matcher, inv_shift_matcher)),
+ IsMerge(IsIfTrue(branch_eqz_matcher),
+ IsIfFalse(branch_eqz_matcher))),
+ IsPhi(MachineRepresentation::kWord32, high_matcher,
+ IsWord32Or(IsWord32Shr(high_matcher, shift_matcher),
+ IsWord32Shl(low_matcher, inv_shift_matcher)),
+ IsMerge(IsIfTrue(branch_eqz_matcher),
+ IsIfFalse(branch_eqz_matcher))),
+ start(), start()));
+}
+
+TEST_F(Int64LoweringTest, I64Ror_0) {
+ LowerGraph(graph()->NewNode(machine()->Word64Ror(), Int64Constant(value(0)),
+ Int32Constant(0)),
+ MachineRepresentation::kWord64);
+
+ EXPECT_THAT(graph()->end()->InputAt(1),
+ IsReturn2(IsInt32Constant(low_word_value(0)),
+ IsInt32Constant(high_word_value(0)), start(), start()));
+}
+
+TEST_F(Int64LoweringTest, I64Ror_32) {
+ LowerGraph(graph()->NewNode(machine()->Word64Ror(), Int64Constant(value(0)),
+ Int32Constant(32)),
+ MachineRepresentation::kWord64);
+
+ EXPECT_THAT(graph()->end()->InputAt(1),
+ IsReturn2(IsInt32Constant(high_word_value(0)),
+ IsInt32Constant(low_word_value(0)), start(), start()));
+}
+
+TEST_F(Int64LoweringTest, I64Ror_11) {
+ LowerGraph(graph()->NewNode(machine()->Word64Ror(), Int64Constant(value(0)),
+ Int32Constant(11)),
+ MachineRepresentation::kWord64);
+
+ EXPECT_THAT(
+ graph()->end()->InputAt(1),
+ IsReturn2(IsWord32Or(IsWord32Shr(IsInt32Constant(low_word_value(0)),
+ IsInt32Constant(11)),
+ IsWord32Shl(IsInt32Constant(high_word_value(0)),
+ IsInt32Constant(21))),
+ IsWord32Or(IsWord32Shr(IsInt32Constant(high_word_value(0)),
+ IsInt32Constant(11)),
+ IsWord32Shl(IsInt32Constant(low_word_value(0)),
+ IsInt32Constant(21))),
+ start(), start()));
+}
+
+TEST_F(Int64LoweringTest, I64Ror_43) {
+ LowerGraph(graph()->NewNode(machine()->Word64Ror(), Int64Constant(value(0)),
+ Int32Constant(43)),
+ MachineRepresentation::kWord64);
+
+ EXPECT_THAT(
+ graph()->end()->InputAt(1),
+ IsReturn2(IsWord32Or(IsWord32Shr(IsInt32Constant(high_word_value(0)),
+ IsInt32Constant(11)),
+ IsWord32Shl(IsInt32Constant(low_word_value(0)),
+ IsInt32Constant(21))),
+ IsWord32Or(IsWord32Shr(IsInt32Constant(low_word_value(0)),
+ IsInt32Constant(11)),
+ IsWord32Shl(IsInt32Constant(high_word_value(0)),
+ IsInt32Constant(21))),
+ start(), start()));
+}
+
TEST_F(Int64LoweringTest, I64PhiWord64) {
LowerGraph(graph()->NewNode(common()->Phi(MachineRepresentation::kWord64, 2),
Int64Constant(value(0)), Int64Constant(value(1)),
« src/compiler/int64-lowering.cc ('K') | « test/cctest/wasm/test-run-wasm-64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine