Commit 9a112b54 authored by Manos Koukoutos's avatar Manos Koukoutos Committed by Commit Bot

[wasm] Chain diamond patterns to current control in wasm compiler

Diamond patterns need to be chained to the current control node. This
was not done consistently in wasm code, particularly the parts
implementing asm-js specific instructions.

Additionally, the graph structure for BuildI32AsmjsDivS is improved.

Change-Id: I4a17e431b5795c197bf56dd034ff5e7d95dd6db0
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2578982Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Manos Koukoutos <manoskouk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71677}
parent 0ad21093
...@@ -2532,7 +2532,7 @@ Node* WasmGraphBuilder::BuildI32AsmjsDivS(Node* left, Node* right) { ...@@ -2532,7 +2532,7 @@ Node* WasmGraphBuilder::BuildI32AsmjsDivS(Node* left, Node* right) {
// asm.js semantics return 0 on divide or mod by zero. // asm.js semantics return 0 on divide or mod by zero.
if (m->Int32DivIsSafe()) { if (m->Int32DivIsSafe()) {
// The hardware instruction does the right thing (e.g. arm). // The hardware instruction does the right thing (e.g. arm).
return graph()->NewNode(m->Int32Div(), left, right, graph()->start()); return graph()->NewNode(m->Int32Div(), left, right, control());
} }
// Check denominator for zero. // Check denominator for zero.
...@@ -2540,20 +2540,22 @@ Node* WasmGraphBuilder::BuildI32AsmjsDivS(Node* left, Node* right) { ...@@ -2540,20 +2540,22 @@ Node* WasmGraphBuilder::BuildI32AsmjsDivS(Node* left, Node* right) {
graph(), mcgraph()->common(), graph(), mcgraph()->common(),
graph()->NewNode(m->Word32Equal(), right, mcgraph()->Int32Constant(0)), graph()->NewNode(m->Word32Equal(), right, mcgraph()->Int32Constant(0)),
BranchHint::kFalse); BranchHint::kFalse);
z.Chain(control());
// Check numerator for -1. (avoid minint / -1 case). // Check denominator for -1. (avoid minint / -1 case).
Diamond n( Diamond n(
graph(), mcgraph()->common(), graph(), mcgraph()->common(),
graph()->NewNode(m->Word32Equal(), right, mcgraph()->Int32Constant(-1)), graph()->NewNode(m->Word32Equal(), right, mcgraph()->Int32Constant(-1)),
BranchHint::kFalse); BranchHint::kFalse);
n.Chain(z.if_false);
Node* div = graph()->NewNode(m->Int32Div(), left, right, n.if_false);
Node* div = graph()->NewNode(m->Int32Div(), left, right, z.if_false);
Node* neg = Node* neg =
graph()->NewNode(m->Int32Sub(), mcgraph()->Int32Constant(0), left); graph()->NewNode(m->Int32Sub(), mcgraph()->Int32Constant(0), left);
return n.Phi( return z.Phi(MachineRepresentation::kWord32, mcgraph()->Int32Constant(0),
MachineRepresentation::kWord32, neg, n.Phi(MachineRepresentation::kWord32, neg, div));
z.Phi(MachineRepresentation::kWord32, mcgraph()->Int32Constant(0), div));
} }
Node* WasmGraphBuilder::BuildI32AsmjsRemS(Node* left, Node* right) { Node* WasmGraphBuilder::BuildI32AsmjsRemS(Node* left, Node* right) {
...@@ -2596,7 +2598,7 @@ Node* WasmGraphBuilder::BuildI32AsmjsRemS(Node* left, Node* right) { ...@@ -2596,7 +2598,7 @@ Node* WasmGraphBuilder::BuildI32AsmjsRemS(Node* left, Node* right) {
Node* check0 = graph()->NewNode(m->Int32LessThan(), zero, right); Node* check0 = graph()->NewNode(m->Int32LessThan(), zero, right);
Node* branch0 = Node* branch0 =
graph()->NewNode(c->Branch(BranchHint::kTrue), check0, graph()->start()); graph()->NewNode(c->Branch(BranchHint::kTrue), check0, control());
Node* if_true0 = graph()->NewNode(c->IfTrue(), branch0); Node* if_true0 = graph()->NewNode(c->IfTrue(), branch0);
Node* true0; Node* true0;
...@@ -2659,7 +2661,7 @@ Node* WasmGraphBuilder::BuildI32AsmjsDivU(Node* left, Node* right) { ...@@ -2659,7 +2661,7 @@ Node* WasmGraphBuilder::BuildI32AsmjsDivU(Node* left, Node* right) {
// asm.js semantics return 0 on divide or mod by zero. // asm.js semantics return 0 on divide or mod by zero.
if (m->Uint32DivIsSafe()) { if (m->Uint32DivIsSafe()) {
// The hardware instruction does the right thing (e.g. arm). // The hardware instruction does the right thing (e.g. arm).
return graph()->NewNode(m->Uint32Div(), left, right, graph()->start()); return graph()->NewNode(m->Uint32Div(), left, right, control());
} }
// Explicit check for x % 0. // Explicit check for x % 0.
...@@ -2667,6 +2669,7 @@ Node* WasmGraphBuilder::BuildI32AsmjsDivU(Node* left, Node* right) { ...@@ -2667,6 +2669,7 @@ Node* WasmGraphBuilder::BuildI32AsmjsDivU(Node* left, Node* right) {
graph(), mcgraph()->common(), graph(), mcgraph()->common(),
graph()->NewNode(m->Word32Equal(), right, mcgraph()->Int32Constant(0)), graph()->NewNode(m->Word32Equal(), right, mcgraph()->Int32Constant(0)),
BranchHint::kFalse); BranchHint::kFalse);
z.Chain(control());
return z.Phi(MachineRepresentation::kWord32, mcgraph()->Int32Constant(0), return z.Phi(MachineRepresentation::kWord32, mcgraph()->Int32Constant(0),
graph()->NewNode(mcgraph()->machine()->Uint32Div(), left, right, graph()->NewNode(mcgraph()->machine()->Uint32Div(), left, right,
...@@ -2681,6 +2684,7 @@ Node* WasmGraphBuilder::BuildI32AsmjsRemU(Node* left, Node* right) { ...@@ -2681,6 +2684,7 @@ Node* WasmGraphBuilder::BuildI32AsmjsRemU(Node* left, Node* right) {
graph(), mcgraph()->common(), graph(), mcgraph()->common(),
graph()->NewNode(m->Word32Equal(), right, mcgraph()->Int32Constant(0)), graph()->NewNode(m->Word32Equal(), right, mcgraph()->Int32Constant(0)),
BranchHint::kFalse); BranchHint::kFalse);
z.Chain(control());
Node* rem = graph()->NewNode(mcgraph()->machine()->Uint32Mod(), left, right, Node* rem = graph()->NewNode(mcgraph()->machine()->Uint32Mod(), left, right,
z.if_false); z.if_false);
......
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