From a8d5d176598c131bb16b0c9767facf7d768c2d68 Mon Sep 17 00:00:00 2001 From: ahaas Date: Wed, 24 Feb 2016 01:51:30 -0800 Subject: [PATCH] [wasm] Added I64Xor to the Int64Lowering. R=titzer@chromium.org Review URL: https://codereview.chromium.org/1723613002 Cr-Commit-Position: refs/heads/master@{#34241} --- src/compiler/int64-lowering.cc | 14 ++++++++++++++ src/compiler/wasm-compiler.cc | 6 +++--- test/cctest/wasm/test-run-wasm-64.cc | 7 +++++++ test/unittests/compiler/int64-lowering-unittest.cc | 13 +++++++++++++ test/unittests/compiler/node-test-utils.cc | 1 + test/unittests/compiler/node-test-utils.h | 2 ++ 6 files changed, 40 insertions(+), 3 deletions(-) diff --git a/src/compiler/int64-lowering.cc b/src/compiler/int64-lowering.cc index 48f461da0e..2c32b962c3 100644 --- a/src/compiler/int64-lowering.cc +++ b/src/compiler/int64-lowering.cc @@ -274,6 +274,20 @@ void Int64Lowering::LowerNode(Node* node) { } // kExprI64Xor: + case IrOpcode::kWord64Xor: { + DCHECK(node->InputCount() == 2); + Node* left = node->InputAt(0); + Node* right = node->InputAt(1); + + Node* low_node = + graph()->NewNode(machine()->Word32Xor(), GetReplacementLow(left), + GetReplacementLow(right)); + Node* high_node = + graph()->NewNode(machine()->Word32Xor(), GetReplacementHigh(left), + GetReplacementHigh(right)); + ReplaceNode(node, low_node, high_node); + break; + } // kExprI64Shl: // kExprI64ShrU: // kExprI64ShrS: diff --git a/src/compiler/wasm-compiler.cc b/src/compiler/wasm-compiler.cc index b8ebfd8542..9b0692267a 100644 --- a/src/compiler/wasm-compiler.cc +++ b/src/compiler/wasm-compiler.cc @@ -500,6 +500,9 @@ Node* WasmGraphBuilder::Binop(wasm::WasmOpcode opcode, Node* left, op = m->Word64Or(); break; // kExprI64Xor: + case wasm::kExprI64Xor: + op = m->Word64Xor(); + break; // kExprI64Shl: // kExprI64ShrU: // kExprI64ShrS: @@ -583,9 +586,6 @@ Node* WasmGraphBuilder::Binop(wasm::WasmOpcode opcode, Node* left, op = m->Uint64Mod(); return graph()->NewNode(op, left, right, trap_->ZeroCheck64(kTrapRemByZero, right)); - case wasm::kExprI64Xor: - op = m->Word64Xor(); - break; case wasm::kExprI64Shl: op = m->Word64Shl(); break; diff --git a/test/cctest/wasm/test-run-wasm-64.cc b/test/cctest/wasm/test-run-wasm-64.cc index 3dc5a3a373..2a1cfe2d9b 100644 --- a/test/cctest/wasm/test-run-wasm-64.cc +++ b/test/cctest/wasm/test-run-wasm-64.cc @@ -43,6 +43,13 @@ TEST(Run_WasmI64Ior) { } } // kExprI64Xor: +TEST(Run_WasmI64Xor) { + WasmRunner r(MachineType::Int64(), MachineType::Int64()); + BUILD(r, WASM_I64_XOR(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); + FOR_INT64_INPUTS(i) { + FOR_INT64_INPUTS(j) { CHECK_EQ((*i) ^ (*j), r.Call(*i, *j)); } + } +} // kExprI64Shl: // kExprI64ShrU: // kExprI64ShrS: diff --git a/test/unittests/compiler/int64-lowering-unittest.cc b/test/unittests/compiler/int64-lowering-unittest.cc index b9300cb9ab..924213c7fc 100644 --- a/test/unittests/compiler/int64-lowering-unittest.cc +++ b/test/unittests/compiler/int64-lowering-unittest.cc @@ -320,6 +320,19 @@ TEST_F(Int64LoweringTest, Int64Ior) { } // kExprI64Xor: +TEST_F(Int64LoweringTest, Int64Xor) { + if (4 != kPointerSize) return; + + LowerGraph(graph()->NewNode(machine()->Word64Xor(), Int64Constant(value(0)), + Int64Constant(value(1))), + MachineRepresentation::kWord64); + EXPECT_THAT(graph()->end()->InputAt(1), + IsReturn2(IsWord32Xor(IsInt32Constant(low_word_value(0)), + IsInt32Constant(low_word_value(1))), + IsWord32Xor(IsInt32Constant(high_word_value(0)), + IsInt32Constant(high_word_value(1))), + start(), start())); +} // kExprI64Shl: // kExprI64ShrU: // kExprI64ShrS: diff --git a/test/unittests/compiler/node-test-utils.cc b/test/unittests/compiler/node-test-utils.cc index ee4cf5446e..d534767239 100644 --- a/test/unittests/compiler/node-test-utils.cc +++ b/test/unittests/compiler/node-test-utils.cc @@ -2085,6 +2085,7 @@ IS_BINOP_MATCHER(NumberShiftRight) IS_BINOP_MATCHER(NumberShiftRightLogical) IS_BINOP_MATCHER(Word32And) IS_BINOP_MATCHER(Word32Or) +IS_BINOP_MATCHER(Word32Xor) IS_BINOP_MATCHER(Word32Sar) IS_BINOP_MATCHER(Word32Shl) IS_BINOP_MATCHER(Word32Shr) diff --git a/test/unittests/compiler/node-test-utils.h b/test/unittests/compiler/node-test-utils.h index 03f2a3b88f..1875ce9102 100644 --- a/test/unittests/compiler/node-test-utils.h +++ b/test/unittests/compiler/node-test-utils.h @@ -265,6 +265,8 @@ Matcher IsWord32And(const Matcher& lhs_matcher, const Matcher& rhs_matcher); Matcher IsWord32Or(const Matcher& lhs_matcher, const Matcher& rhs_matcher); +Matcher IsWord32Xor(const Matcher& lhs_matcher, + const Matcher& rhs_matcher); Matcher IsWord32Sar(const Matcher& lhs_matcher, const Matcher& rhs_matcher); Matcher IsWord32Shl(const Matcher& lhs_matcher,