5#ifndef V8_COMPILER_TURBOSHAFT_VARIABLE_REDUCER_H_
6#define V8_COMPILER_TURBOSHAFT_VARIABLE_REDUCER_H_
57template <
class AfterNext>
64 return var.
data().active_loop_variables_index;
80 if (var.
data().loop_invariant) {
85 }
else if (!old_value.
valid() && new_value.
valid()) {
95 Next::Bind(new_block);
101 std::optional<Snapshot> pred_snapshot =
103 DCHECK(pred_snapshot.has_value());
108 auto merge_variables =
110 for (
OpIndex idx : predecessors) {
115 }
else if (
__ output_graph()
120 return __ LoadRootRegister();
128 if (new_block->IsLoop()) {
134 if (active_loop_variables_begin != active_loop_variables_end) {
142 pending_phis.
push_back({var, pending_loop_phi});
173 for (
auto [var, pending_phi_idx] :
177 __ output_graph().template Replace<PhiOp>(
195 if (
V8_UNLIKELY(
__ generating_unreachable_operations()))
return;
198 template <
typename Rep>
201 if (
V8_UNLIKELY(
__ generating_unreachable_operations()))
return;
247 for (
OpIndex idx : frame_states_indices) {
256 for (
auto frame_state : frame_states) {
268 bool all_parent_frame_states_are_the_same =
true;
269 for (
auto frame_state : frame_states) {
270 indices_to_merge.
push_back(frame_state->parent_frame_state());
271 all_parent_frame_states_are_the_same =
272 all_parent_frame_states_are_the_same &&
274 frame_state->parent_frame_state();
276 if (all_parent_frame_states_are_the_same) {
279 OpIndex merged_parent_frame_state =
281 new_inputs.
push_back(merged_parent_frame_state);
288 bool all_inputs_are_the_same =
true;
289 for (
auto frame_state : frame_states) {
290 indices_to_merge.
push_back(frame_state->state_value(
i));
291 all_inputs_are_the_same =
292 all_inputs_are_the_same &&
295 if (all_inputs_are_the_same) {
324 std::optional<ZoneVector<std::pair<Variable, OpIndex>>>>
#define REDUCE(operation)
void push_back(const T &value)
NeighboringPredecessorIterable PredecessorsIterable() const
void Set(Key key, Value new_value)
Key NewKey(KeyData data, Value initial_value=Value{})
void StartNewSnapshot(base::Vector< const Snapshot > predecessors)
static constexpr MaybeRegisterRepresentation None()
static constexpr OpIndex Invalid()
constexpr bool valid() const
OpIndex REDUCE Phi(base::Vector< const OpIndex > inputs, RegisterRepresentation rep)
const KeyData & data() const
const Value & Get(Key key) const
const Value & GetPredecessorValue(Key key, int predecessor_index)
OpIndex GetPredecessorValue(Variable var, int predecessor_index)
OpIndex MergeFrameState(base::Vector< const OpIndex > frame_states_indices)
void RestoreTemporaryVariableSnapshotAfter(const Block *block)
ZoneVector< Snapshot > predecessors_
void CloseTemporaryVariableSnapshot()
void Set(Variable var, V< Rep > value)
OpIndex MergeOpIndices(base::Vector< const OpIndex > inputs, MaybeRegisterRepresentation maybe_rep)
Variable NewLoopInvariantVariable(MaybeRegisterRepresentation rep)
void Bind(Block *new_block)
OpIndex GetVariable(Variable var)
V< None > REDUCE Goto(Block *destination, bool is_backedge)
void SealAndSaveVariableSnapshot()
void SetVariable(Variable var, OpIndex new_index)
Variable NewVariable(MaybeRegisterRepresentation rep)
ZoneAbslFlatHashMap< BlockIndex, std::optional< ZoneVector< std::pair< Variable, OpIndex > > > > loop_pending_phis_
const Block * current_block_
GrowingBlockSidetable< std::optional< Snapshot > > block_to_snapshot_mapping_
#define TURBOSHAFT_REDUCER_BOILERPLATE(Name)
ZoneVector< RpoNumber > & result
InstructionOperand destination
constexpr Vector< T > VectorOf(T *start, size_t size)
V8_INLINE const Operation & Get(const Graph &graph, OpIndex index)
bool Is(IndirectHandle< U > value)
Tagged< To > Cast(Tagged< From > value, const v8::SourceLocation &loc=INIT_SOURCE_LOCATION_IN_DEBUG)
#define DCHECK_NOT_NULL(val)
#define DCHECK_NE(v1, v2)
#define DCHECK(condition)
#define DCHECK_EQ(v1, v2)
OpIndex parent_frame_state() const
const OpIndex state_value(size_t idx) const
uint16_t state_values_count() const
const FrameStateData * data
RegisterRepresentation state_value_rep(size_t idx) const
const uint16_t input_count
RegisterRepresentation rep
IntrusiveSetIndex & operator()(Variable var) const
void OnValueChange(Variable var, OpIndex old_value, OpIndex new_value)
ZoneIntrusiveSet< Variable, GetActiveLoopVariablesIndex > active_loop_variables
void OnNewKey(Variable var, OpIndex value)
VariableTable(Zone *zone)
#define V8_UNLIKELY(condition)