98#define DEBUG_TYPE "irce"
106class InductiveRangeCheck {
108 const SCEV *Begin =
nullptr;
109 const SCEV *Step =
nullptr;
111 Use *CheckUse =
nullptr;
113 friend class InductiveRangeCheckElimination;
121 const SCEV *getBegin()
const {
return Begin; }
122 const SCEV *getStep()
const {
return Step; }
123 const SCEV *getEnd()
const {
return End; }
126 OS <<
"InductiveRangeCheck:\n";
133 OS <<
"\n CheckUse: ";
134 getCheckUse()->getUser()->print(OS);
135 OS <<
" Operand: " << getCheckUse()->getOperandNo() <<
"\n";
143 Use *getCheckUse()
const {
return CheckUse; }
158 const SCEV *getBegin()
const {
return Begin; }
159 const SCEV *getEnd()
const {
return End; }
172 bool getPassingDirection() {
return true; }
180 const ScalarOptions &Opts)
const;
183class InductiveRangeCheckElimination {
184 const ScalarOptions &Opts;
196 std::optional<uint64_t> estimatedTripCount(
const Loop &L);
201 void extractRangeChecksFromCond(
Loop *L,
Use &ConditionUse,
205 bool reassociateSubLHS(
Loop *L,
Value *VariantLHS,
Value *InvariantRHS,
214 void extractRangeChecksFromBranch(
215 CondBrInst *BI,
Loop *L, std::optional<uint64_t> EstimatedTripCount,
219 InductiveRangeCheckElimination(
const ScalarOptions &Opts,
ScalarEvolution &SE,
221 LoopInfo &LI, GetBFIFunc GetBFI =
nullptr)
222 : Opts(Opts), SE(SE), BPI(BPI), DT(DT), LI(LI), GetBFI(GetBFI) {}
233bool InductiveRangeCheckElimination::parseRangeCheckICmp(
235 auto IsLoopInvariant = [
this,
L](
Value *
V) {
247 if (IsLoopInvariant(
LHS)) {
250 }
else if (!IsLoopInvariant(
RHS))
254 if (InductiveRangeCheck::parseIvAgaisntLimit(L,
LHS,
RHS, Pred, SE, Index,
258 if (reassociateSubLHS(L,
LHS,
RHS, Pred, Index,
End))
267 ICmpInst::Predicate Pred,
269 const SCEVAddRecExpr *&Index,
272 auto SIntMaxSCEV = [&](
Type *
T) {
289 case ICmpInst::ICMP_SGE:
292 End = SIntMaxSCEV(
Index->getType());
297 case ICmpInst::ICMP_SGT:
300 End = SIntMaxSCEV(
Index->getType());
305 case ICmpInst::ICMP_SLT:
306 case ICmpInst::ICMP_ULT:
311 case ICmpInst::ICMP_SLE:
312 case ICmpInst::ICMP_ULE:
315 bool Signed = Pred == ICmpInst::ICMP_SLE;
329bool InductiveRangeCheckElimination::reassociateSubLHS(
330 Loop *L,
Value *VariantLHS,
Value *InvariantRHS, ICmpInst::Predicate Pred,
331 const SCEVAddRecExpr *&Index,
const SCEV *&
End) {
338 const SCEV *Limit = SE.
getSCEV(InvariantRHS);
340 bool OffsetSubtracted =
false;
346 OffsetSubtracted =
true;
394 const SCEV *
RHS) ->
const SCEV * {
399 case Instruction::Add:
401 case Instruction::Sub:
413 if (Ty->getBitWidth() > Opts.irce_max_type_size_for_overflow_check)
421 if (OffsetSubtracted)
423 Limit = getExprScaledIfOverflow(Instruction::BinaryOps::Add,
Offset, Limit);
426 Limit = getExprScaledIfOverflow(Instruction::BinaryOps::Sub,
Offset, Limit);
427 Pred = ICmpInst::getSwappedPredicate(Pred);
430 if (Pred == ICmpInst::ICMP_SLT || Pred == ICmpInst::ICMP_SLE) {
432 if (Pred == ICmpInst::ICMP_SLE && Limit)
433 Limit = getExprScaledIfOverflow(Instruction::BinaryOps::Add, Limit,
444void InductiveRangeCheckElimination::extractRangeChecksFromCond(
445 Loop *L, Use &ConditionUse, SmallVectorImpl<InductiveRangeCheck> &Checks,
446 SmallPtrSetImpl<Value *> &Visited) {
447 Value *Condition = ConditionUse.
get();
448 if (!Visited.
insert(Condition).second)
453 extractRangeChecksFromCond(L,
cast<User>(Condition)->getOperandUse(0),
455 extractRangeChecksFromCond(L,
cast<User>(Condition)->getOperandUse(1),
464 const SCEV *
End =
nullptr;
465 const SCEVAddRecExpr *IndexAddRec =
nullptr;
466 if (!parseRangeCheckICmp(L, ICI, IndexAddRec,
End))
469 assert(IndexAddRec &&
"IndexAddRec was not computed");
475 InductiveRangeCheck IRC;
477 IRC.Begin = IndexAddRec->
getStart();
479 IRC.CheckUse = &ConditionUse;
483void InductiveRangeCheckElimination::extractRangeChecksFromBranch(
484 CondBrInst *BI,
Loop *L, std::optional<uint64_t> EstimatedTripCount,
485 SmallVectorImpl<InductiveRangeCheck> &Checks,
bool &
Changed) {
489 unsigned IndexLoopSucc =
L->contains(BI->
getSuccessor(0)) ? 0 : 1;
491 "No edges coming to loop?");
493 if (!Opts.irce_skip_profitability_checks && BPI) {
494 auto SuccessProbability =
496 if (EstimatedTripCount) {
497 auto EstimatedEliminatedChecks =
498 SuccessProbability.scale(*EstimatedTripCount);
499 if (EstimatedEliminatedChecks < Opts.irce_min_eliminated_checks) {
500 LLVM_DEBUG(
dbgs() <<
"irce: could not prove profitability for branch "
502 <<
"estimated eliminated checks too low "
503 << EstimatedEliminatedChecks <<
"\n";);
507 BranchProbability LikelyTaken(15, 16);
508 if (SuccessProbability < LikelyTaken) {
509 LLVM_DEBUG(
dbgs() <<
"irce: could not prove profitability for branch "
511 <<
"could not estimate trip count "
512 <<
"and branch success probability too low "
513 << SuccessProbability <<
"\n";);
521 if (IndexLoopSucc != 0) {
529 SmallPtrSet<Value *, 8> Visited;
530 extractRangeChecksFromCond(L, BI->
getOperandUse(0), Checks, Visited);
543static std::optional<LoopConstrainer::SubRanges>
545 const Loop &L, InductiveRangeCheck::Range &
Range,
549 if (!Opts.irce_allow_narrow_latch && RTy != MainLoopStructure.
ExitCountTy)
561 RTy, SE, IsSignedPredicate);
563 SE, IsSignedPredicate);
571 const SCEV *Smallest =
nullptr, *Greatest =
nullptr, *GreatestSeen =
nullptr;
597 GreatestSeen = Start;
600 auto Clamp = [&SE, Smallest, Greatest, IsSignedPredicate](
const SCEV *S) {
601 return IsSignedPredicate
612 bool ProvablyNoPreloop =
614 if (!ProvablyNoPreloop)
615 Result.LowLimit = Clamp(
Range.getBegin());
617 bool ProvablyNoPostLoop =
619 if (!ProvablyNoPostLoop)
620 Result.HighLimit = Clamp(
Range.getEnd());
628std::optional<InductiveRangeCheck::Range>
629InductiveRangeCheck::computeSafeIterationSpace(
630 ScalarEvolution &SE,
const SCEVAddRecExpr *IndVar,
bool IsLatchSigned,
631 const ScalarOptions &Opts)
const {
638 if (!IVType || !RCType)
640 if (IVType->getBitWidth() > RCType->getBitWidth())
671 assert(!
B->isZero() &&
"Recurrence with zero step?");
673 const SCEV *
C = getBegin();
678 assert(!
D->getValue()->isZero() &&
"Recurrence with zero step?");
679 unsigned BitWidth = RCType->getBitWidth();
695 auto ClampedSubtract = [&](
const SCEV *
X,
const SCEV *
Y) {
731 auto SCEVCheckNonNegative = [&](
const SCEV *
X) ->
const SCEV * {
734 const SCEV *One = SE.
getOne(
X->getType());
748 auto SCEVCheckWillNotOverflow = [&](
const SCEV *
X) {
752 const SCEV *OverflowCheck =
758 const SCEV *UnderflowCheck =
761 return SE.
getMulExpr(OverflowCheck, UnderflowCheck);
772 const SCEV *REnd = getEnd();
773 const SCEV *EndWillNotOverflow = SE.
getOne(RCType);
775 auto PrintRangeCheck = [&](raw_ostream &OS) {
777 OS <<
"irce: in function ";
778 OS <<
L->getHeader()->getParent()->getName();
781 OS <<
"there is range check with scaled boundary:\n";
785 if (EndType->getBitWidth() > RCType->getBitWidth()) {
786 assert(EndType->getBitWidth() == RCType->getBitWidth() * 2);
787 if (Opts.irce_print_scaled_boundary_range_checks)
788 PrintRangeCheck(
errs());
797 const SCEV *RuntimeChecks =
798 SE.
getMulExpr(SCEVCheckNonNegative(REnd), EndWillNotOverflow);
799 const SCEV *Begin = SE.
getMulExpr(ClampedSubtract(Zero, M), RuntimeChecks);
800 const SCEV *
End = SE.
getMulExpr(ClampedSubtract(REnd, M), RuntimeChecks);
802 return InductiveRangeCheck::Range(Begin,
End);
805static std::optional<InductiveRangeCheck::Range>
807 const std::optional<InductiveRangeCheck::Range> &R1,
808 const InductiveRangeCheck::Range &
R2) {
809 if (
R2.isEmpty(SE,
true))
816 assert(!R1Value.isEmpty(SE,
true) &&
817 "We should never have empty R1!");
821 if (R1Value.getType() !=
R2.getType())
828 auto Ret = InductiveRangeCheck::Range(NewBegin, NewEnd);
829 if (Ret.isEmpty(SE,
true))
834static std::optional<InductiveRangeCheck::Range>
836 const std::optional<InductiveRangeCheck::Range> &R1,
837 const InductiveRangeCheck::Range &
R2) {
838 if (
R2.isEmpty(SE,
false))
845 assert(!R1Value.isEmpty(SE,
false) &&
846 "We should never have empty R1!");
850 if (R1Value.getType() !=
R2.getType())
857 auto Ret = InductiveRangeCheck::Range(NewBegin, NewEnd);
858 if (Ret.isEmpty(SE,
false))
864 const ScalarOptions &Opts = ScalarOptions::Global;
879 InductiveRangeCheckElimination IRCE(Opts, SE, &BPI, DT, LI, {getBFI});
883 bool CFGChanged =
false;
884 for (
const auto &L : LI) {
885 CFGChanged |=
simplifyLoop(L, &DT, &LI, &SE,
nullptr,
nullptr,
891 if (CFGChanged && !Opts.irce_skip_profitability_checks) {
901 auto LPMAddNewLoop = [&Worklist](
Loop *NL,
bool IsSubloop) {
906 while (!Worklist.
empty()) {
908 if (IRCE.run(L, LPMAddNewLoop)) {
910 if (!Opts.irce_skip_profitability_checks) {
924std::optional<uint64_t>
925InductiveRangeCheckElimination::estimatedTripCount(
const Loop &L) {
930 if (phFreq == 0 || hFreq == 0)
932 return {hFreq / phFreq};
938 auto *Latch =
L.getLoopLatch();
945 auto LatchBrExitIdx = LatchBr->getSuccessor(0) ==
L.getHeader() ? 1 : 0;
946 BranchProbability ExitProbability =
954bool InductiveRangeCheckElimination::run(
955 Loop *L, function_ref<
void(
Loop *,
bool)> LPMAddNewLoop) {
956 if (
L->getBlocks().size() >= Opts.irce_loop_size_cutoff) {
957 LLVM_DEBUG(
dbgs() <<
"irce: giving up constraining loop, too large\n");
967 auto EstimatedTripCount = estimatedTripCount(*L);
968 if (!Opts.irce_skip_profitability_checks && EstimatedTripCount &&
969 *EstimatedTripCount < Opts.irce_min_eliminated_checks) {
971 <<
"the estimated number of iterations is "
972 << *EstimatedTripCount <<
"\n");
980 for (
auto *BBI :
L->getBlocks())
982 extractRangeChecksFromBranch(TBI, L, EstimatedTripCount, RangeChecks,
985 if (RangeChecks.
empty())
988 auto PrintRecognizedRangeChecks = [&](raw_ostream &OS) {
989 OS <<
"irce: looking at loop ";
L->print(OS);
990 OS <<
"irce: loop has " << RangeChecks.
size()
991 <<
" inductive range checks: \n";
992 for (InductiveRangeCheck &IRC : RangeChecks)
998 if (Opts.irce_print_range_checks)
999 PrintRecognizedRangeChecks(
errs());
1001 const char *FailureReason =
nullptr;
1002 SCEVExpander LoopStructureExpander(SE,
"loop-constrainer");
1003 SCEVExpanderCleaner LoopStructureExpanderCleaner(LoopStructureExpander);
1004 std::optional<LoopStructure> MaybeLoopStructure =
1006 Opts.irce_allow_unsigned_latch,
1008 if (!MaybeLoopStructure) {
1010 << FailureReason <<
"\n";);
1013 LoopStructure
LS = *MaybeLoopStructure;
1014 const SCEVAddRecExpr *IndVar =
1017 std::optional<InductiveRangeCheck::Range> SafeIterRange;
1024 auto IntersectRange =
1027 for (InductiveRangeCheck &IRC : RangeChecks) {
1029 IRC.computeSafeIterationSpace(SE, IndVar,
LS.IsSignedPredicate, Opts);
1031 auto MaybeSafeIterRange = IntersectRange(SE, SafeIterRange, *Result);
1032 if (MaybeSafeIterRange) {
1033 assert(!MaybeSafeIterRange->isEmpty(SE,
LS.IsSignedPredicate) &&
1034 "We should never return empty ranges!");
1036 SafeIterRange = *MaybeSafeIterRange;
1044 std::optional<LoopConstrainer::SubRanges> MaybeSR =
1051 LoopConstrainer LC(*L, LI, LPMAddNewLoop, LS, SE, DT,
1052 SafeIterRange->getBegin()->getType(), *MaybeSR);
1055 LoopStructureExpanderCleaner.markResultUsed();
1056 LS.IndVarStart->setName(
"indvar.start");
1059 auto PrintConstrainedLoopInfo = [
L]() {
1060 dbgs() <<
"irce: in function ";
1061 dbgs() <<
L->getHeader()->getParent()->getName() <<
": ";
1062 dbgs() <<
"constrained ";
1068 if (Opts.irce_print_changed_loops)
1069 PrintConstrainedLoopInfo();
1073 for (InductiveRangeCheck &IRC : RangeChecksToEliminate) {
1074 ConstantInt *FoldedRangeCheck = IRC.getPassingDirection()
1077 IRC.getCheckUse()->set(FoldedRangeCheck);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file implements a class to represent arbitrary precision integral constant values and operations...
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
This file declares an analysis pass that computes CycleInfo for LLVM IR, specialized from GenericCycl...
This file provides various utilities for inspecting and working with the control flow graph in LLVM I...
Module.h This file contains the declarations for the Module class.
This defines the Use class.
static const SCEV * NoopOrExtend(const SCEV *S, Type *Ty, ScalarEvolution &SE, bool Signed)
If the type of S matches with Ty, return S.
static std::optional< LoopConstrainer::SubRanges > calculateSubRanges(const ScalarOptions &Opts, ScalarEvolution &SE, const Loop &L, InductiveRangeCheck::Range &Range, const LoopStructure &MainLoopStructure)
static std::optional< InductiveRangeCheck::Range > IntersectSignedRange(ScalarEvolution &SE, const std::optional< InductiveRangeCheck::Range > &R1, const InductiveRangeCheck::Range &R2)
static std::optional< InductiveRangeCheck::Range > IntersectUnsignedRange(ScalarEvolution &SE, const std::optional< InductiveRangeCheck::Range > &R1, const InductiveRangeCheck::Range &R2)
static Constant * getFalse(Type *Ty)
For a boolean type or a vector of boolean type, return false or a vector with every element false.
This header provides classes for managing per-loop analyses.
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
PowerPC Reduce CR logical Operation
This file provides a priority worklist.
This file defines the SmallPtrSet class.
This file defines the SmallVector class.
static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")
static SymbolRef::Type getType(const Symbol *Sym)
static const uint32_t IV[8]
static APInt getSignedMaxValue(unsigned numBits)
Gets maximum signed value of APInt for a specific bit width.
static APInt getSignedMinValue(unsigned numBits)
Gets minimum signed value of APInt for a specific bit width.
void invalidate(IRUnitT &IR, const PreservedAnalyses &PA)
Invalidate cached analyses for an IR unit.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
LLVM_ABI LLVMContext & getContext() const
Get the context in which this basic block lives.
Analysis pass which computes BlockFrequencyInfo.
BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...
LLVM_ABI BlockFrequency getBlockFreq(const BasicBlock *BB) const
getblockFreq - Return block frequency.
uint64_t getFrequency() const
Returns the frequency as a fixpoint number scaled by the entry frequency.
Analysis pass which computes BranchProbabilityInfo.
Analysis providing branch probability information.
LLVM_ABI BranchProbability getEdgeProbability(const BasicBlock *Src, unsigned IndexInSuccessors) const
Get an edge's probability, relative to other out-edges of the Src.
LLVM_ABI void swapSuccEdgesProbabilities(const BasicBlock *Src)
Swap outgoing edges probabilities for Src with branch terminator.
LLVM_ABI uint64_t scaleByInverse(uint64_t Num) const
Scale a large integer by the inverse.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
@ ICMP_SLT
signed less than
@ ICMP_SLE
signed less or equal
@ ICMP_UGE
unsigned greater or equal
@ ICMP_ULT
unsigned less than
@ ICMP_SGE
signed greater or equal
@ ICMP_ULE
unsigned less or equal
Predicate getSwappedPredicate() const
For example, EQ->EQ, SLE->SGE, ULT->UGT, OEQ->OEQ, ULE->UGE, OLT->OGT, etc.
Predicate getPredicate() const
Return the predicate for this instruction.
Conditional Branch instruction.
BasicBlock * getSuccessor(unsigned i) const
static LLVM_ABI ConstantInt * getTrue(LLVMContext &Context)
Analysis pass which computes a CycleInfo.
Analysis pass which computes a DominatorTree.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
This instruction compares its operands according to the predicate given to the constructor.
LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
static LLVM_ABI IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
unsigned getBitWidth() const
Get the number of bits in this IntegerType.
Analysis pass that exposes the LoopInfo for a function.
Represents a single loop in the control flow graph.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
PreservedAnalyses & abandon()
Mark an analysis as abandoned.
bool empty() const
Determine if the PriorityWorklist is empty or not.
This node represents a polynomial recurrence on the trip count of the specified loop.
bool isAffine() const
Return true if this represents an expression A + B*x where A and B are loop invariant values.
const Loop * getLoop() const
SCEVUse getStepRecurrence(ScalarEvolution &SE) const
Constructs and returns the recurrence indicating how much this expression steps by.
This class represents an analyzed expression in the program.
static constexpr auto FlagNUW
static constexpr auto FlagNSW
Type * getType() const
Return the LLVM type of this SCEV expression.
LLVM_ABI void print(raw_ostream &OS) const
Print out the internal representation of this scalar to the specified stream.
Analysis pass that exposes the ScalarEvolution for a function.
The main scalar evolution driver.
LLVM_ABI const SCEV * getSMinExpr(SCEVUse LHS, SCEVUse RHS)
const SCEV * getZero(Type *Ty)
Return a SCEV for the constant 0 of a specific type.
LLVM_ABI bool willNotOverflow(Instruction::BinaryOps BinOp, bool Signed, const SCEV *LHS, const SCEV *RHS, const Instruction *CtxI=nullptr)
Is operation BinOp between LHS and RHS provably does not have a signed/unsigned overflow (Signed)?
LLVM_ABI const SCEV * getMinusSCEV(SCEVUse LHS, SCEVUse RHS, SCEVFlags Flags=SCEV::FlagNone, unsigned Depth=0)
Return LHS-RHS.
LLVM_ABI const SCEV * getConstant(ConstantInt *V)
LLVM_ABI const SCEV * getSCEV(Value *V)
Return a SCEV expression for the full generality of the specified expression.
LLVM_ABI const SCEV * getNoopOrSignExtend(const SCEV *V, Type *Ty)
Return a SCEV corresponding to a conversion of the input value to the specified type.
const SCEV * getOne(Type *Ty)
Return a SCEV for the constant 1 of a specific type.
LLVM_ABI bool isLoopInvariant(const SCEV *S, const Loop *L)
Return true if the value of the given SCEV is unchanging in the specified loop.
LLVM_ABI const SCEV * getTruncateExpr(SCEVUse Op, Type *Ty, unsigned Depth=0)
LLVM_ABI SCEVUse getAddExpr(SmallVectorImpl< SCEVUse > &Ops, SCEVFlagsPair Flags={}, unsigned Depth=0)
Get a canonical add expression, or something simpler if possible.
LLVM_ABI const SCEV * getSignExtendExpr(SCEVUse Op, Type *Ty, unsigned Depth=0)
LLVM_ABI const SCEV * getUMaxExpr(SCEVUse LHS, SCEVUse RHS)
LLVM_ABI const SCEV * getNoopOrZeroExtend(const SCEV *V, Type *Ty)
Return a SCEV corresponding to a conversion of the input value to the specified type.
LLVM_ABI SCEVUse getMulExpr(SmallVectorImpl< SCEVUse > &Ops, SCEVFlagsPair Flags={}, unsigned Depth=0)
Get a canonical multiply expression, or something simpler if possible.
LLVM_ABI bool isKnownPredicate(CmpPredicate Pred, SCEVUse LHS, SCEVUse RHS)
Test if the given expression is known to satisfy the condition described by Pred, LHS,...
LLVM_ABI const SCEV * getSMaxExpr(SCEVUse LHS, SCEVUse RHS)
LLVM_ABI const SCEV * getNegativeSCEV(const SCEV *V, SCEVFlags Flags=SCEV::FlagNone)
Return the SCEV object corresponding to -V.
LLVM_ABI const SCEV * getUMinExpr(SCEVUse LHS, SCEVUse RHS, bool Sequential=false)
A version of PriorityWorklist that selects small size optimized data structures for the vector and ma...
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
The instances of the Type class are immutable: once they are created, they are never changed.
bool isIntegerTy() const
True if this is an instance of IntegerType.
A Use represents the edge between a Value definition and its users.
const Use & getOperandUse(unsigned i) const
Value * getOperand(unsigned i) const
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
An efficient, type-erasing, non-owning reference to a callable.
const ParentTy * getParent() const
This class implements an extremely fast bulk output stream that can only output to a stream.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ BasicBlock
Various leaf nodes.
bool match(Val *V, const Pattern &P)
auto m_Value()
Match an arbitrary value and ignore it.
auto m_LogicalAnd()
Matches L && R where L and R are arbitrary values.
BinaryOp_match< LHS, RHS, Instruction::Sub > m_Sub(const LHS &L, const RHS &R)
auto m_ConstantInt()
Match an arbitrary ConstantInt and ignore it.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI bool simplifyLoop(Loop *L, DominatorTree *DT, LoopInfo *LI, ScalarEvolution *SE, AssumptionCache *AC, MemorySSAUpdater *MSSAU, bool PreserveLCSSA)
Simplify each loop in a loop nest recursively.
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
Printable print(const GCNRegPressure &RP, const GCNSubtarget *ST=nullptr, unsigned DynamicVGPRBlockSize=0)
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI bool formLCSSARecursively(Loop &L, const DominatorTree &DT, const LoopInfo *LI, ScalarEvolution *SE)
Put a loop nest into LCSSA form.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
LLVM_ABI void InvertBranch(CondBrInst *PBI, IRBuilderBase &Builder)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
IRBuilder(LLVMContext &, FolderTy, InserterTy) -> IRBuilder< FolderTy, InserterTy >
LLVM_TEMPLATE_ABI void appendLoopsToWorklist(RangeT &&, SmallPriorityWorklist< Loop *, 4 > &)
Utility that implements appending of loops onto a worklist given a range.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
LLVM_ABI bool isKnownNegativeInLoop(const SCEV *S, const Loop *L, ScalarEvolution &SE)
Returns true if we can prove that S is defined and always negative in loop L.
constexpr unsigned BitWidth
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI PreservedAnalyses getLoopPassPreservedAnalyses()
Returns the minimum set of Analyses that all loop passes must preserve.
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
@ End
Run the machine verifier once, at the end of the pipeline.
LLVM_ABI bool isKnownNonNegativeInLoop(const SCEV *S, const Loop *L, ScalarEvolution &SE)
Returns true if we can prove that S is defined and always non-negative in loop L.
SCEVUseT< const SCEV * > SCEVUse
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
static LLVM_ABI std::optional< LoopStructure > parseLoopStructure(SCEVExpander &Expander, Loop &L, bool AllowUnsignedLatchCond, const char *&FailureReason)
Parse L and use Expander to materialize values needed by the parsed structure.
IntegerType * ExitCountTy