[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/+/2578982 Reviewed-by: Jakob Kummerow <jkummerow@chromium.org> Commit-Queue: Manos Koukoutos <manoskouk@chromium.org> Cr-Commit-Position: refs/heads/master@{#71677}
This commit is contained in:
parent
0ad2109351
commit
9a112b549b
@ -2532,7 +2532,7 @@ Node* WasmGraphBuilder::BuildI32AsmjsDivS(Node* left, Node* right) {
|
||||
// asm.js semantics return 0 on divide or mod by zero.
|
||||
if (m->Int32DivIsSafe()) {
|
||||
// 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.
|
||||
@ -2540,20 +2540,22 @@ Node* WasmGraphBuilder::BuildI32AsmjsDivS(Node* left, Node* right) {
|
||||
graph(), mcgraph()->common(),
|
||||
graph()->NewNode(m->Word32Equal(), right, mcgraph()->Int32Constant(0)),
|
||||
BranchHint::kFalse);
|
||||
z.Chain(control());
|
||||
|
||||
// Check numerator for -1. (avoid minint / -1 case).
|
||||
// Check denominator for -1. (avoid minint / -1 case).
|
||||
Diamond n(
|
||||
graph(), mcgraph()->common(),
|
||||
graph()->NewNode(m->Word32Equal(), right, mcgraph()->Int32Constant(-1)),
|
||||
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 =
|
||||
graph()->NewNode(m->Int32Sub(), mcgraph()->Int32Constant(0), left);
|
||||
|
||||
return n.Phi(
|
||||
MachineRepresentation::kWord32, neg,
|
||||
z.Phi(MachineRepresentation::kWord32, mcgraph()->Int32Constant(0), div));
|
||||
return z.Phi(MachineRepresentation::kWord32, mcgraph()->Int32Constant(0),
|
||||
n.Phi(MachineRepresentation::kWord32, neg, div));
|
||||
}
|
||||
|
||||
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* 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* true0;
|
||||
@ -2659,7 +2661,7 @@ Node* WasmGraphBuilder::BuildI32AsmjsDivU(Node* left, Node* right) {
|
||||
// asm.js semantics return 0 on divide or mod by zero.
|
||||
if (m->Uint32DivIsSafe()) {
|
||||
// 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.
|
||||
@ -2667,6 +2669,7 @@ Node* WasmGraphBuilder::BuildI32AsmjsDivU(Node* left, Node* right) {
|
||||
graph(), mcgraph()->common(),
|
||||
graph()->NewNode(m->Word32Equal(), right, mcgraph()->Int32Constant(0)),
|
||||
BranchHint::kFalse);
|
||||
z.Chain(control());
|
||||
|
||||
return z.Phi(MachineRepresentation::kWord32, mcgraph()->Int32Constant(0),
|
||||
graph()->NewNode(mcgraph()->machine()->Uint32Div(), left, right,
|
||||
@ -2681,6 +2684,7 @@ Node* WasmGraphBuilder::BuildI32AsmjsRemU(Node* left, Node* right) {
|
||||
graph(), mcgraph()->common(),
|
||||
graph()->NewNode(m->Word32Equal(), right, mcgraph()->Int32Constant(0)),
|
||||
BranchHint::kFalse);
|
||||
z.Chain(control());
|
||||
|
||||
Node* rem = graph()->NewNode(mcgraph()->machine()->Uint32Mod(), left, right,
|
||||
z.if_false);
|
||||
|
Loading…
Reference in New Issue
Block a user