#include "src/compiler/turboshaft/loop-unrolling-reducer.h"
#include <optional>
#include "src/base/bits.h"
#include "src/compiler/turboshaft/index.h"
#include "src/compiler/turboshaft/loop-finder.h"
namespace v8::internal::compiler::turboshaft {
CmpOp;
BinOp;
void LoopUnrollingAnalyzer::DetectUnrollableLoops() { … }
IterationCount LoopUnrollingAnalyzer::GetLoopIterationCount(
const LoopFinder::LoopInfo& info) const { … }
bool StaticCanonicalForLoopMatcher::MatchPhiCompareCst(
OpIndex cond_idx, StaticCanonicalForLoopMatcher::CmpOp* cmp_op,
OpIndex* phi, uint64_t* cst) const { … }
bool StaticCanonicalForLoopMatcher::MatchCheckedOverflowBinop(
OpIndex idx, V<Word>* left, V<Word>* right, BinOp* binop_op,
WordRepresentation* binop_rep) const { … }
bool StaticCanonicalForLoopMatcher::MatchWordBinop(
OpIndex idx, V<Word>* left, V<Word>* right, BinOp* binop_op,
WordRepresentation* binop_rep) const { … }
IterationCount
StaticCanonicalForLoopMatcher::GetIterCountIfStaticCanonicalForLoop(
const Block* header, OpIndex cond_idx, bool loop_if_cond_is) const { … }
constexpr bool StaticCanonicalForLoopMatcher::BinopKindIsSupported(
WordBinopOp::Kind binop_kind) { … }
constexpr StaticCanonicalForLoopMatcher::BinOp
StaticCanonicalForLoopMatcher::BinopFromWordBinopKind(WordBinopOp::Kind kind) { … }
constexpr StaticCanonicalForLoopMatcher::BinOp
StaticCanonicalForLoopMatcher::BinopFromOverflowCheckedBinopKind(
OverflowCheckedBinopOp::Kind kind) { … }
std::ostream& operator<<(std::ostream& os, const IterationCount& count) { … }
std::ostream& operator<<(std::ostream& os, const CmpOp& cmp) { … }
std::ostream& operator<<(std::ostream& os, const BinOp& binop) { … }
namespace {
template <class Int>
std::optional<Int> Next(Int val, Int incr,
StaticCanonicalForLoopMatcher::BinOp binop_op,
WordRepresentation binop_rep) { … }
template <class Int>
bool Cmp(Int val, Int max, CmpOp cmp_op) { … }
template <class Int>
bool SubWillOverflow(Int lhs, Int rhs) { … }
template <class Int>
bool DivWillOverflow(Int dividend, Int divisor) { … }
}
template <class Int>
IterationCount StaticCanonicalForLoopMatcher::CountIterationsImpl(
Int init, Int max, CmpOp cmp_op, Int binop_cst, BinOp binop_op,
WordRepresentation binop_rep, bool loop_if_cond_is) const { … }
IterationCount StaticCanonicalForLoopMatcher::CountIterations(
uint64_t cmp_cst, CmpOp cmp_op, uint64_t initial_input, uint64_t binop_cst,
BinOp binop_op, WordRepresentation binop_rep, bool loop_if_cond_is) const { … }
constexpr StaticCanonicalForLoopMatcher::CmpOp
StaticCanonicalForLoopMatcher::ComparisonKindToCmpOp(ComparisonOp::Kind kind) { … }
constexpr StaticCanonicalForLoopMatcher::CmpOp
StaticCanonicalForLoopMatcher::InvertComparisonOp(CmpOp op) { … }
}