5#ifndef V8_COMPILER_TURBOSHAFT_VALUE_NUMBERING_REDUCER_H_
6#define V8_COMPILER_TURBOSHAFT_VALUE_NUMBERING_REDUCER_H_
89 template <
class Reducer>
93 scopes_ = reducer->gvn_disabled_scope();
108#if defined(__clang__)
116 template <
typename Op>
121 if constexpr (
MayThrow(opcode))
return false;
122 if constexpr (opcode == Opcode::kCatchBlockBegin) {
129 if constexpr (opcode == Opcode::kComment) {
136#define EMIT_OP(Name) \
137 template <class... Args> \
138 OpIndex Reduce##Name(Args... args) { \
139 OpIndex next_index = Asm().output_graph().next_operation_index(); \
141 OpIndex result = Next::Reduce##Name(args...); \
142 if (ShouldSkipOptimizationStep()) return result; \
143 if constexpr (!CanBeGVNed<Name##Op>()) return result; \
144 DCHECK_EQ(next_index, result); \
145 return AddOrFind<Name##Op>(result); \
165 target = target->GetDominator();
170 target = target->GetDominator();
199 const Op& op = Asm().output_graph().Get(op_idx).template
Cast<Op>();
200 if (std::is_same_v<Op, PendingLoopPhiOp> || op.IsBlockTerminator() ||
201 (!op.Effects().repetition_is_eliminatable() &&
202 !std::is_same_v<Op, DeoptimizeIfOp>)) {
213 *entry =
Entry{op_idx, Asm().current_block()->index(), hash,
221 Next::RemoveLast(op_idx);
228 constexpr bool same_block_only = std::is_same<Op, PhiOp>::value;
230 size_t start_index = hash &
mask_;
236 if (hash_ret) *hash_ret = hash;
239 if (entry.
hash == hash) {
240 const Operation& entry_op = Asm().output_graph().Get(entry.
value);
241 if (entry_op.
Is<Op>() &&
243 entry.
block == Asm().current_block()->
index()) &&
244 entry_op.
Cast<Op>().EqualsForGVN(op)) {
270 Asm().phase_zone()->template NewVector<Entry>(
table_.size() * 2);
273 for (
size_t depth_idx = 0; depth_idx <
depths_heads_.size(); depth_idx++) {
309 while (entry !=
nullptr) {
311 if (new_table[
i].hash == 0) {
312 new_table[
i] = *entry;
324 template <
bool same_block_only,
class Op>
326 size_t hash = op.hash_value();
327 if (same_block_only) {
347 std::max<size_t>(128, Asm().input_graph().op_id_capacity() / 2)));
DisableValueNumbering(Reducer *reducer)
Derived * GetDominator() const
ScopeCounter * gvn_disabled_scope()
Entry * NextEntry(Entry *entry)
Entry * PrevEntry(Entry *entry)
base::Vector< Entry > table_
void ClearCurrentDepthEntries()
bool WillGVNOp(const Op &op)
ZoneVector< Block * > dominator_path_
void ResetToBlock(Block *block)
size_t NextEntryIndex(size_t index)
ScopeCounter disabled_scope_
Entry * Find(const Op &op, size_t *hash_ret=nullptr)
size_t ComputeHash(const Op &op)
static constexpr bool CanBeGVNed()
ZoneVector< Entry * > depths_heads_
OpIndex AddOrFind(OpIndex op_idx)
#define TURBOSHAFT_REDUCER_BOILERPLATE(Name)
constexpr size_t RoundUpToPowerOfTwo(size_t value)
constexpr Opcode operation_to_opcode_v
constexpr bool MayThrow(Opcode opcode)
V8_INLINE size_t fast_hash_combine()
Tagged< To > Cast(Tagged< From > value, const v8::SourceLocation &loc=INIT_SOURCE_LOCATION_IN_DEBUG)
#define TURBOSHAFT_OPERATION_LIST(V)
#define DCHECK_NE(v1, v2)
underlying_operation_t< Op > & Cast()
Entry * depth_neighboring_entry
#define V8_LIKELY(condition)
#define V8_UNLIKELY(condition)