#include "llvm/Transforms/Utils/LoopConstrainer.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/ScalarEvolution.h"
#include "llvm/Analysis/ScalarEvolutionExpressions.h"
#include "llvm/IR/Dominators.h"
#include "llvm/Transforms/Utils/Cloning.h"
#include "llvm/Transforms/Utils/LoopSimplify.h"
#include "llvm/Transforms/Utils/LoopUtils.h"
#include "llvm/Transforms/Utils/ScalarEvolutionExpander.h"
usingnamespacellvm;
static const char *ClonedLoopTag = …;
#define DEBUG_TYPE …
static bool isSafeDecreasingBound(const SCEV *Start, const SCEV *BoundSCEV,
const SCEV *Step, ICmpInst::Predicate Pred,
unsigned LatchBrExitIdx, Loop *L,
ScalarEvolution &SE) { … }
static bool isSafeIncreasingBound(const SCEV *Start, const SCEV *BoundSCEV,
const SCEV *Step, ICmpInst::Predicate Pred,
unsigned LatchBrExitIdx, Loop *L,
ScalarEvolution &SE) { … }
static const SCEV *getNarrowestLatchMaxTakenCountEstimate(ScalarEvolution &SE,
const Loop &L) { … }
std::optional<LoopStructure>
LoopStructure::parseLoopStructure(ScalarEvolution &SE, Loop &L,
bool AllowUnsignedLatchCond,
const char *&FailureReason) { … }
static void DisableAllLoopOptsOnLoop(Loop &L) { … }
LoopConstrainer::LoopConstrainer(Loop &L, LoopInfo &LI,
function_ref<void(Loop *, bool)> LPMAddNewLoop,
const LoopStructure &LS, ScalarEvolution &SE,
DominatorTree &DT, Type *T, SubRanges SR)
: … { … }
void LoopConstrainer::cloneLoop(LoopConstrainer::ClonedLoop &Result,
const char *Tag) const { … }
LoopConstrainer::RewrittenRangeInfo LoopConstrainer::changeIterationSpaceEnd(
const LoopStructure &LS, BasicBlock *Preheader, Value *ExitSubloopAt,
BasicBlock *ContinuationBlock) const { … }
void LoopConstrainer::rewriteIncomingValuesForPHIs(
LoopStructure &LS, BasicBlock *ContinuationBlock,
const LoopConstrainer::RewrittenRangeInfo &RRI) const { … }
BasicBlock *LoopConstrainer::createPreheader(const LoopStructure &LS,
BasicBlock *OldPreheader,
const char *Tag) const { … }
void LoopConstrainer::addToParentLoopIfNeeded(ArrayRef<BasicBlock *> BBs) { … }
Loop *LoopConstrainer::createClonedLoopStructure(Loop *Original, Loop *Parent,
ValueToValueMapTy &VM,
bool IsSubloop) { … }
bool LoopConstrainer::run() { … }