Commit 0c390238 authored by Manos Koukoutos's avatar Manos Koukoutos Committed by V8 LUCI CQ

[turbofan] Allow unique or multiple control path states

Templetize ControlPathState on whether multiple states are allowed for the same node. Instantiate BranchElimination to allow a single state
per node, and WasmGCOperatorReducer to allow multiple.
This fixes a performance regression caused by crrev.com/c/3717994.

Bug: chromium:1339826
Change-Id: Id52d643daad618f45c3d8509f2a661e177609a0c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3754941
Commit-Queue: Manos Koukoutos <manoskouk@chromium.org>
Reviewed-by: 's avatarNico Hartmann <nicohartmann@chromium.org>
Cr-Commit-Position: refs/heads/main@{#81772}
parent 4aa3dd83
...@@ -52,10 +52,6 @@ Reduction BranchElimination::Reduce(Node* node) { ...@@ -52,10 +52,6 @@ Reduction BranchElimination::Reduce(Node* node) {
} }
} }
namespace {
using ControlPathConditions = ControlPathState<BranchCondition>;
}
void BranchElimination::SimplifyBranchCondition(Node* branch) { void BranchElimination::SimplifyBranchCondition(Node* branch) {
// Try to use a phi as a branch condition if the control flow from the branch // Try to use a phi as a branch condition if the control flow from the branch
// is known from previous branches. For example, in the graph below, the // is known from previous branches. For example, in the graph below, the
......
...@@ -40,8 +40,8 @@ struct BranchCondition { ...@@ -40,8 +40,8 @@ struct BranchCondition {
}; };
class V8_EXPORT_PRIVATE BranchElimination final class V8_EXPORT_PRIVATE BranchElimination final
: public NON_EXPORTED_BASE( : public NON_EXPORTED_BASE(AdvancedReducerWithControlPathState)<
AdvancedReducerWithControlPathState<BranchCondition>) { BranchCondition, kUniqueInstance> {
public: public:
enum Phase { enum Phase {
kEARLY, kEARLY,
...@@ -56,6 +56,9 @@ class V8_EXPORT_PRIVATE BranchElimination final ...@@ -56,6 +56,9 @@ class V8_EXPORT_PRIVATE BranchElimination final
Reduction Reduce(Node* node) final; Reduction Reduce(Node* node) final;
private: private:
using ControlPathConditions =
ControlPathState<BranchCondition, kUniqueInstance>;
Reduction ReduceBranch(Node* node); Reduction ReduceBranch(Node* node);
Reduction ReduceDeoptimizeConditional(Node* node); Reduction ReduceDeoptimizeConditional(Node* node);
Reduction ReduceIf(Node* node, bool is_true_branch); Reduction ReduceIf(Node* node, bool is_true_branch);
...@@ -65,10 +68,10 @@ class V8_EXPORT_PRIVATE BranchElimination final ...@@ -65,10 +68,10 @@ class V8_EXPORT_PRIVATE BranchElimination final
Reduction ReduceStart(Node* node); Reduction ReduceStart(Node* node);
Reduction ReduceOtherControl(Node* node); Reduction ReduceOtherControl(Node* node);
void SimplifyBranchCondition(Node* branch); void SimplifyBranchCondition(Node* branch);
Reduction UpdateStatesHelper( Reduction UpdateStatesHelper(Node* node,
Node* node, ControlPathState<BranchCondition> prev_conditions, ControlPathConditions prev_conditions,
Node* current_condition, Node* current_branch, bool is_true_branch, Node* current_condition, Node* current_branch,
bool in_new_block) { bool is_true_branch, bool in_new_block) {
return UpdateStates( return UpdateStates(
node, prev_conditions, current_condition, node, prev_conditions, current_condition,
BranchCondition(current_condition, current_branch, is_true_branch), BranchCondition(current_condition, current_branch, is_true_branch),
......
This diff is collapsed.
...@@ -40,7 +40,8 @@ struct NodeWithType { ...@@ -40,7 +40,8 @@ struct NodeWithType {
// arguments. Although types have been assigned to nodes already, this class // arguments. Although types have been assigned to nodes already, this class
// also tracks additional type information along control paths. // also tracks additional type information along control paths.
class WasmGCOperatorReducer final class WasmGCOperatorReducer final
: public AdvancedReducerWithControlPathState<NodeWithType> { : public AdvancedReducerWithControlPathState<NodeWithType,
kMultipleInstances> {
public: public:
WasmGCOperatorReducer(Editor* editor, Zone* temp_zone_, MachineGraph* mcgraph, WasmGCOperatorReducer(Editor* editor, Zone* temp_zone_, MachineGraph* mcgraph,
const wasm::WasmModule* module); const wasm::WasmModule* module);
...@@ -50,7 +51,7 @@ class WasmGCOperatorReducer final ...@@ -50,7 +51,7 @@ class WasmGCOperatorReducer final
Reduction Reduce(Node* node) final; Reduction Reduce(Node* node) final;
private: private:
using ControlPathTypes = ControlPathState<NodeWithType>; using ControlPathTypes = ControlPathState<NodeWithType, kMultipleInstances>;
Reduction ReduceAssertNotNull(Node* node); Reduction ReduceAssertNotNull(Node* node);
Reduction ReduceCheckNull(Node* node); Reduction ReduceCheckNull(Node* node);
......
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