Commit 5caabdd5 authored by bgeron's avatar bgeron Committed by Commit bot

[turbofan] Improve the store-store elimination.

It can now deal with multiple objects at the same time (but no
aliasing), and it propagates store information upwards across effect
chain splits.

R=jarin
BUG=

Review-Url: https://codereview.chromium.org/2159303002
Cr-Commit-Position: refs/heads/master@{#38509}
parent 652e1e6d
...@@ -1058,12 +1058,36 @@ struct EffectControlLinearizationPhase { ...@@ -1058,12 +1058,36 @@ struct EffectControlLinearizationPhase {
} }
}; };
// The store-store elimination greatly benefits from doing a common operator
// reducer just before it, to eliminate conditional deopts with a constant
// condition.
struct DeadCodeEliminationPhase {
static const char* phase_name() { return "common operator reducer"; }
void Run(PipelineData* data, Zone* temp_zone) {
// Run the common operator reducer.
JSGraphReducer graph_reducer(data->jsgraph(), temp_zone);
DeadCodeElimination dead_code_elimination(&graph_reducer, data->graph(),
data->common());
CommonOperatorReducer common_reducer(&graph_reducer, data->graph(),
data->common(), data->machine());
AddReducer(data, &graph_reducer, &dead_code_elimination);
AddReducer(data, &graph_reducer, &common_reducer);
graph_reducer.ReduceGraph();
}
};
struct StoreStoreEliminationPhase { struct StoreStoreEliminationPhase {
static const char* phase_name() { return "Store-store elimination"; } static const char* phase_name() { return "store-store elimination"; }
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
StoreStoreElimination store_store_elimination(data->jsgraph(), temp_zone); GraphTrimmer trimmer(temp_zone, data->graph());
store_store_elimination.Run(); NodeVector roots(temp_zone);
data->jsgraph()->GetCachedNodes(&roots);
trimmer.TrimGraph(roots.begin(), roots.end());
StoreStoreElimination::Run(data->jsgraph(), temp_zone);
} }
}; };
...@@ -1554,6 +1578,9 @@ bool PipelineImpl::OptimizeGraph(Linkage* linkage) { ...@@ -1554,6 +1578,9 @@ bool PipelineImpl::OptimizeGraph(Linkage* linkage) {
Run<EffectControlLinearizationPhase>(); Run<EffectControlLinearizationPhase>();
RunPrintAndVerify("Effect and control linearized", true); RunPrintAndVerify("Effect and control linearized", true);
Run<DeadCodeEliminationPhase>();
RunPrintAndVerify("Common operator reducer", true);
if (FLAG_turbo_store_elimination) { if (FLAG_turbo_store_elimination) {
Run<StoreStoreEliminationPhase>(); Run<StoreStoreEliminationPhase>();
RunPrintAndVerify("Store-store elimination", true); RunPrintAndVerify("Store-store elimination", true);
......
This diff is collapsed.
...@@ -6,31 +6,16 @@ ...@@ -6,31 +6,16 @@
#define V8_COMPILER_STORE_STORE_ELIMINATION_H_ #define V8_COMPILER_STORE_STORE_ELIMINATION_H_
#include "src/compiler/common-operator.h" #include "src/compiler/common-operator.h"
#include "src/compiler/graph-reducer.h"
#include "src/compiler/js-graph.h" #include "src/compiler/js-graph.h"
#include "src/zone-containers.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
namespace compiler { namespace compiler {
// Forward declarations.
class CommonOperatorBuilder;
class JSGraph;
class StoreStoreElimination final { class StoreStoreElimination final {
public: public:
StoreStoreElimination(JSGraph* js_graph, Zone* temp_zone); static void Run(JSGraph* js_graph, Zone* temp_zone);
~StoreStoreElimination();
void Run();
private:
static bool IsEligibleNode(Node* node);
void ReduceEligibleNode(Node* node);
JSGraph* jsgraph() const { return jsgraph_; }
Zone* temp_zone() const { return temp_zone_; }
JSGraph* const jsgraph_;
Zone* const temp_zone_;
}; };
} // namespace compiler } // namespace compiler
......
...@@ -356,6 +356,8 @@ DEFINE_STRING(trace_phase, "HLZ", "trace generated IR for specified phases") ...@@ -356,6 +356,8 @@ DEFINE_STRING(trace_phase, "HLZ", "trace generated IR for specified phases")
DEFINE_BOOL(trace_inlining, false, "trace inlining decisions") DEFINE_BOOL(trace_inlining, false, "trace inlining decisions")
DEFINE_BOOL(trace_load_elimination, false, "trace load elimination") DEFINE_BOOL(trace_load_elimination, false, "trace load elimination")
DEFINE_BOOL(trace_store_elimination, false, "trace store elimination") DEFINE_BOOL(trace_store_elimination, false, "trace store elimination")
DEFINE_BOOL(turbo_verify_store_elimination, false,
"verify store elimination more rigorously")
DEFINE_BOOL(trace_alloc, false, "trace register allocator") DEFINE_BOOL(trace_alloc, false, "trace register allocator")
DEFINE_BOOL(trace_all_uses, false, "trace all use positions") DEFINE_BOOL(trace_all_uses, false, "trace all use positions")
DEFINE_BOOL(trace_range, false, "trace range analysis") DEFINE_BOOL(trace_range, false, "trace range analysis")
...@@ -425,7 +427,6 @@ DEFINE_BOOL(omit_map_checks_for_leaf_maps, true, ...@@ -425,7 +427,6 @@ DEFINE_BOOL(omit_map_checks_for_leaf_maps, true,
// Flags for TurboFan. // Flags for TurboFan.
DEFINE_BOOL(turbo, false, "enable TurboFan compiler") DEFINE_BOOL(turbo, false, "enable TurboFan compiler")
DEFINE_IMPLICATION(turbo, turbo_asm_deoptimization) DEFINE_IMPLICATION(turbo, turbo_asm_deoptimization)
DEFINE_IMPLICATION(turbo, turbo_store_elimination)
DEFINE_IMPLICATION(turbo, turbo_loop_peeling) DEFINE_IMPLICATION(turbo, turbo_loop_peeling)
DEFINE_BOOL(turbo_from_bytecode, false, "enable building graphs from bytecode") DEFINE_BOOL(turbo_from_bytecode, false, "enable building graphs from bytecode")
DEFINE_BOOL(turbo_sp_frame_access, false, DEFINE_BOOL(turbo_sp_frame_access, false,
...@@ -487,7 +488,7 @@ DEFINE_BOOL(turbo_instruction_scheduling, false, ...@@ -487,7 +488,7 @@ DEFINE_BOOL(turbo_instruction_scheduling, false,
"enable instruction scheduling in TurboFan") "enable instruction scheduling in TurboFan")
DEFINE_BOOL(turbo_stress_instruction_scheduling, false, DEFINE_BOOL(turbo_stress_instruction_scheduling, false,
"randomly schedule instructions to stress dependency tracking") "randomly schedule instructions to stress dependency tracking")
DEFINE_BOOL(turbo_store_elimination, false, DEFINE_BOOL(turbo_store_elimination, true,
"enable store-store elimination in TurboFan") "enable store-store elimination in TurboFan")
// Flags to help platform porters // Flags to help platform porters
......
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