#include "source/opt/loop_peeling.h"
#include <functional>
#include <memory>
#include <unordered_set>
#include <vector>
#include "source/opt/ir_builder.h"
#include "source/opt/ir_context.h"
#include "source/opt/loop_descriptor.h"
#include "source/opt/loop_utils.h"
#include "source/opt/scalar_analysis.h"
#include "source/opt/scalar_analysis_nodes.h"
namespace spvtools {
namespace opt {
namespace {
void GetBlocksInPath(uint32_t block, uint32_t entry,
std::unordered_set<uint32_t>* blocks_in_path,
const CFG& cfg) { … }
}
size_t LoopPeelingPass::code_grow_threshold_ = …;
void LoopPeeling::DuplicateAndConnectLoop(
LoopUtils::LoopCloningResult* clone_results) { … }
void LoopPeeling::InsertCanonicalInductionVariable(
LoopUtils::LoopCloningResult* clone_results) { … }
void LoopPeeling::GetIteratorUpdateOperations(
const Loop* loop, Instruction* iterator,
std::unordered_set<Instruction*>* operations) { … }
bool LoopPeeling::IsConditionCheckSideEffectFree() const { … }
void LoopPeeling::GetIteratingExitValues() { … }
void LoopPeeling::FixExitCondition(
const std::function<uint32_t(Instruction*)>& condition_builder) { … }
BasicBlock* LoopPeeling::CreateBlockBefore(BasicBlock* bb) { … }
BasicBlock* LoopPeeling::ProtectLoop(Loop* loop, Instruction* condition,
BasicBlock* if_merge) { … }
void LoopPeeling::PeelBefore(uint32_t peel_factor) { … }
void LoopPeeling::PeelAfter(uint32_t peel_factor) { … }
Pass::Status LoopPeelingPass::Process() { … }
bool LoopPeelingPass::ProcessFunction(Function* f) { … }
std::pair<bool, Loop*> LoopPeelingPass::ProcessLoop(Loop* loop,
CodeMetrics* loop_size) { … }
uint32_t LoopPeelingPass::LoopPeelingInfo::GetFirstLoopInvariantOperand(
Instruction* condition) const { … }
uint32_t LoopPeelingPass::LoopPeelingInfo::GetFirstNonLoopInvariantOperand(
Instruction* condition) const { … }
static bool IsHandledCondition(spv::Op opcode) { … }
LoopPeelingPass::LoopPeelingInfo::Direction
LoopPeelingPass::LoopPeelingInfo::GetPeelingInfo(BasicBlock* bb) const { … }
SExpression LoopPeelingPass::LoopPeelingInfo::GetValueAtFirstIteration(
SERecurrentNode* rec) const { … }
SExpression LoopPeelingPass::LoopPeelingInfo::GetValueAtIteration(
SERecurrentNode* rec, int64_t iteration) const { … }
SExpression LoopPeelingPass::LoopPeelingInfo::GetValueAtLastIteration(
SERecurrentNode* rec) const { … }
bool LoopPeelingPass::LoopPeelingInfo::EvalOperator(CmpOperator cmp_op,
SExpression lhs,
SExpression rhs,
bool* result) const { … }
LoopPeelingPass::LoopPeelingInfo::Direction
LoopPeelingPass::LoopPeelingInfo::HandleEquality(SExpression lhs,
SExpression rhs) const { … }
LoopPeelingPass::LoopPeelingInfo::Direction
LoopPeelingPass::LoopPeelingInfo::HandleInequality(CmpOperator cmp_op,
SExpression lhs,
SERecurrentNode* rhs) const { … }
}
}