Commit 18d9da0d authored by ahaas's avatar ahaas Committed by Commit bot

[wasm] I added I64Eq to the Int64Lowering.

(a EQ b) is lowered to ((low(a) XOR low(b)) OR (high(a) XOR high(b))) EQ 0

R=titzer@chromium.org

Review URL: https://codereview.chromium.org/1729493002

Cr-Commit-Position: refs/heads/master@{#34249}
parent 199bfb9b
......@@ -292,6 +292,25 @@ void Int64Lowering::LowerNode(Node* node) {
// kExprI64ShrU:
// kExprI64ShrS:
// kExprI64Eq:
case IrOpcode::kWord64Equal: {
DCHECK(node->InputCount() == 2);
Node* left = node->InputAt(0);
Node* right = node->InputAt(1);
// TODO(wasm): Use explicit comparisons and && here?
Node* replacement = graph()->NewNode(
machine()->Word32Equal(),
graph()->NewNode(
machine()->Word32Or(),
graph()->NewNode(machine()->Word32Xor(), GetReplacementLow(left),
GetReplacementLow(right)),
graph()->NewNode(machine()->Word32Xor(), GetReplacementHigh(left),
GetReplacementHigh(right))),
graph()->NewNode(common()->Int32Constant(0)));
ReplaceNode(node, replacement, nullptr);
break;
}
// kExprI64Ne:
// kExprI64LtS:
// kExprI64LeS:
......
......@@ -507,6 +507,9 @@ Node* WasmGraphBuilder::Binop(wasm::WasmOpcode opcode, Node* left,
// kExprI64ShrU:
// kExprI64ShrS:
// kExprI64Eq:
case wasm::kExprI64Eq:
op = m->Word64Equal();
break;
// kExprI64Ne:
// kExprI64LtS:
// kExprI64LeS:
......@@ -595,9 +598,6 @@ Node* WasmGraphBuilder::Binop(wasm::WasmOpcode opcode, Node* left,
case wasm::kExprI64ShrS:
op = m->Word64Sar();
break;
case wasm::kExprI64Eq:
op = m->Word64Equal();
break;
case wasm::kExprI64Ne:
return Invert(Binop(wasm::kExprI64Eq, left, right));
case wasm::kExprI64LtS:
......
......@@ -54,6 +54,13 @@ TEST(Run_WasmI64Xor) {
// kExprI64ShrU:
// kExprI64ShrS:
// kExprI64Eq:
TEST(Run_WasmI64Eq) {
WasmRunner<int32_t> r(MachineType::Int64(), MachineType::Int64());
BUILD(r, WASM_I64_EQ(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) { CHECK_EQ(*i == *j ? 1 : 0, r.Call(*i, *j)); }
}
}
// kExprI64Ne:
// kExprI64LtS:
// kExprI64LeS:
......
......@@ -337,6 +337,23 @@ TEST_F(Int64LoweringTest, Int64Xor) {
// kExprI64ShrU:
// kExprI64ShrS:
// kExprI64Eq:
TEST_F(Int64LoweringTest, Int64Eq) {
if (4 != kPointerSize) return;
LowerGraph(graph()->NewNode(machine()->Word64Equal(), Int64Constant(value(0)),
Int64Constant(value(1))),
MachineRepresentation::kWord32);
EXPECT_THAT(
graph()->end()->InputAt(1),
IsReturn(IsWord32Equal(
IsWord32Or(IsWord32Xor(IsInt32Constant(low_word_value(0)),
IsInt32Constant(low_word_value(1))),
IsWord32Xor(IsInt32Constant(high_word_value(0)),
IsInt32Constant(high_word_value(1)))),
IsInt32Constant(0)),
start(), start()));
}
// kExprI64Ne:
// kExprI64LtS:
// kExprI64LeS:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment