chromium/v8/src/compiler/turboshaft/required-optimization-reducer.h

// Copyright 2022 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_COMPILER_TURBOSHAFT_REQUIRED_OPTIMIZATION_REDUCER_H_
#define V8_COMPILER_TURBOSHAFT_REQUIRED_OPTIMIZATION_REDUCER_H_

#include "src/compiler/turboshaft/assembler.h"
#include "src/compiler/turboshaft/operations.h"

namespace v8::internal::compiler::turboshaft {

#include "src/compiler/turboshaft/define-assembler-macros.inc"

// The RequiredOptimizationReducer performs reductions that might be needed for
// correctness, because instruction selection or other reducers rely on it. In
// particular, we have the following dependencies:
//   - VariableReducer can introduce phi nodes for call target constants, which
//     have to be reduced in order for instruction selection to detect the call
//     target. So we have to run RequiredOptimizationReducer at least once after
//     every occurence of VariableReducer.
//   - Loop peeling/unrolling can introduce phi nodes for RttCanons, which have
//     to be reduced to aid `WasmGCTypedOptimizationReducer` resolve type
//     indices corresponding to RttCanons.
template <class Next>
class RequiredOptimizationReducer : public Next {};

#include "src/compiler/turboshaft/undef-assembler-macros.inc"

}  // namespace v8::internal::compiler::turboshaft

#endif  // V8_COMPILER_TURBOSHAFT_REQUIRED_OPTIMIZATION_REDUCER_H_