206#define DEBUG_TYPE "loop-predication"
208STATISTIC(TotalConsidered,
"Number of guards considered");
223 LoopICmp() =
default;
225 dbgs() <<
"LoopICmp Pred = " << Pred <<
", IV = " << *IV
226 <<
", Limit = " << *Limit <<
"\n";
230class LoopPredication {
231 const ScalarOptions &Opts;
236 MemorySSAUpdater *MSSAU;
240 const DataLayout *DL;
244 bool isSupportedStep(
const SCEV* Step);
245 std::optional<LoopICmp> parseLoopICmp(ICmpInst *ICI);
246 std::optional<LoopICmp> parseLoopLatchICmp();
257 Instruction *findInsertPt(
const SCEVExpander &Expander, Instruction *User,
263 bool isLoopInvariantValue(
const SCEV* S);
265 Value *expandCheck(SCEVExpander &Expander, Instruction *Guard,
266 ICmpInst::Predicate
Pred,
const SCEV *
LHS,
269 std::optional<Value *> widenICmpRangeCheck(ICmpInst *ICI,
270 SCEVExpander &Expander,
272 std::optional<Value *>
273 widenICmpRangeCheckIncrementingLoop(LoopICmp LatchCheck, LoopICmp RangeCheck,
274 SCEVExpander &Expander,
276 std::optional<Value *>
277 widenICmpRangeCheckDecrementingLoop(LoopICmp LatchCheck, LoopICmp RangeCheck,
278 SCEVExpander &Expander,
280 void widenChecks(SmallVectorImpl<Value *> &Checks,
281 SmallVectorImpl<Value *> &WidenedChecks,
282 SCEVExpander &Expander, Instruction *Guard);
283 bool widenGuardConditions(IntrinsicInst *
II, SCEVExpander &Expander);
284 bool widenWidenableBranchGuardConditions(CondBrInst *Guard,
285 SCEVExpander &Expander);
290 bool isLoopProfitableToPredicate();
292 bool predicateLoopExits(
Loop *L, SCEVExpander &
Rewriter);
295 LoopPredication(
const ScalarOptions &Opts,
AliasAnalysis *AA,
296 DominatorTree *DT, ScalarEvolution *SE, LoopInfo *LI,
297 MemorySSAUpdater *MSSAU, AssumptionCache *AC)
298 : Opts(Opts), AA(AA), DT(DT), SE(SE), LI(LI), MSSAU(MSSAU), AC(AC) {};
299 bool runOnLoop(
Loop *L);
307 std::unique_ptr<MemorySSAUpdater> MSSAU;
309 MSSAU = std::make_unique<MemorySSAUpdater>(AR.
MSSA);
311 LoopPredication LP(Opts, &AR.
AA, &AR.
DT, &AR.
SE, &AR.
LI,
312 MSSAU ? MSSAU.get() :
nullptr, &AR.
AC);
313 if (!LP.runOnLoop(&L))
322std::optional<LoopICmp> LoopPredication::parseLoopICmp(
ICmpInst *ICI) {
327 const SCEV *LHSS = SE->getSCEV(LHS);
330 const SCEV *RHSS = SE->getSCEV(RHS);
335 if (SE->isLoopInvariant(LHSS, L)) {
345 return LoopICmp(
Pred, AR, RHSS);
353 assert(Ty ==
RHS->
getType() &&
"expandCheck operands have different types?");
355 if (SE->isLoopInvariant(
LHS, L) && SE->isLoopInvariant(
RHS, L)) {
357 if (SE->isLoopEntryGuardedByCond(L,
Pred,
LHS,
RHS))
358 return Builder.getTrue();
361 return Builder.getFalse();
368 IRBuilder<> Builder(findInsertPt(Guard, {LHSV, RHSV}));
388 const LoopICmp LatchCheck,
389 Type *RangeCheckType) {
390 if (!Opts.loop_predication_enable_iv_truncation)
392 assert(
DL.getTypeSizeInBits(LatchCheck.IV->
getType()).getFixedValue() >
393 DL.getTypeSizeInBits(RangeCheckType).getFixedValue() &&
394 "Expected latch check IV type to be larger than range check operand "
400 if (!Limit || !Start)
412 auto RangeCheckTypeBitSize =
413 DL.getTypeSizeInBits(RangeCheckType).getFixedValue();
414 return Start->getAPInt().getActiveBits() < RangeCheckTypeBitSize &&
415 Limit->getAPInt().getActiveBits() < RangeCheckTypeBitSize;
423 const LoopICmp LatchCheck,
424 Type *RangeCheckType) {
426 auto *LatchType = LatchCheck.IV->
getType();
427 if (RangeCheckType == LatchType)
430 if (
DL.getTypeSizeInBits(LatchType).getFixedValue() <
431 DL.getTypeSizeInBits(RangeCheckType).getFixedValue())
437 LoopICmp NewLatchCheck;
438 NewLatchCheck.Pred = LatchCheck.Pred;
441 if (!NewLatchCheck.IV)
443 NewLatchCheck.Limit = SE.
getTruncateExpr(LatchCheck.Limit, RangeCheckType);
445 <<
"can be represented as range check type:"
446 << *RangeCheckType <<
"\n");
447 LLVM_DEBUG(
dbgs() <<
"LatchCheck.IV: " << *NewLatchCheck.IV <<
"\n");
448 LLVM_DEBUG(
dbgs() <<
"LatchCheck.Limit: " << *NewLatchCheck.Limit <<
"\n");
449 return NewLatchCheck;
452bool LoopPredication::isSupportedStep(
const SCEV* Step) {
454 Opts.loop_predication_enable_count_down_loop);
460 if (!
L->isLoopInvariant(
Op))
462 return Preheader->getTerminator();
472 if (!SE->isLoopInvariant(
Op, L) ||
475 return Preheader->getTerminator();
478bool LoopPredication::isLoopInvariantValue(
const SCEV* S) {
498 if (SE->isLoopInvariant(S, L))
508 if (LI->isUnordered() &&
L->hasLoopInvariantOperands(LI))
509 if (!
isModSet(
AA->getModRefInfoMask(LI->getOperand(0))) ||
510 LI->hasMetadata(LLVMContext::MD_invariant_load))
515std::optional<Value *> LoopPredication::widenICmpRangeCheckIncrementingLoop(
516 LoopICmp LatchCheck, LoopICmp RangeCheck,
SCEVExpander &Expander,
518 auto *Ty = RangeCheck.IV->
getType();
526 const SCEV *GuardLimit = RangeCheck.Limit;
528 const SCEV *LatchLimit = LatchCheck.Limit;
532 if (!isLoopInvariantValue(GuardStart) ||
533 !isLoopInvariantValue(GuardLimit) ||
534 !isLoopInvariantValue(LatchStart) ||
535 !isLoopInvariantValue(LatchLimit)) {
547 SE->getAddExpr(SE->getMinusSCEV(GuardLimit, GuardStart),
548 SE->getMinusSCEV(LatchStart, SE->getOne(Ty)));
549 auto LimitCheckPred =
557 expandCheck(Expander, Guard, LimitCheckPred, LatchLimit,
RHS);
558 auto *FirstIterationCheck = expandCheck(Expander, Guard, RangeCheck.Pred,
559 GuardStart, GuardLimit);
560 IRBuilder<> Builder(findInsertPt(Guard, {FirstIterationCheck, LimitCheck}));
562 Builder.CreateAnd(FirstIterationCheck, LimitCheck));
565std::optional<Value *> LoopPredication::widenICmpRangeCheckDecrementingLoop(
566 LoopICmp LatchCheck, LoopICmp RangeCheck,
SCEVExpander &Expander,
568 auto *Ty = RangeCheck.IV->
getType();
570 const SCEV *GuardLimit = RangeCheck.Limit;
572 const SCEV *LatchLimit = LatchCheck.Limit;
576 if (!isLoopInvariantValue(GuardStart) ||
577 !isLoopInvariantValue(GuardLimit) ||
578 !isLoopInvariantValue(LatchStart) ||
579 !isLoopInvariantValue(LatchLimit)) {
591 if (RangeCheck.IV != PostDecLatchCheckIV) {
593 << *PostDecLatchCheckIV
594 <<
" and RangeCheckIV: " << *RangeCheck.IV <<
"\n");
602 auto LimitCheckPred =
604 auto *FirstIterationCheck = expandCheck(Expander, Guard,
606 GuardStart, GuardLimit);
607 auto *LimitCheck = expandCheck(Expander, Guard, LimitCheckPred, LatchLimit,
609 IRBuilder<> Builder(findInsertPt(Guard, {FirstIterationCheck, LimitCheck}));
611 Builder.CreateAnd(FirstIterationCheck, LimitCheck));
628std::optional<Value *>
638 auto RangeCheck = parseLoopICmp(ICI);
640 LLVM_DEBUG(
dbgs() <<
"Failed to parse the loop latch condition!\n");
647 << RangeCheck->Pred <<
")!\n");
650 auto *RangeCheckIV = RangeCheck->IV;
651 if (!RangeCheckIV->isAffine()) {
655 const SCEV *Step = RangeCheckIV->getStepRecurrence(*SE);
658 if (!isSupportedStep(Step)) {
659 LLVM_DEBUG(
dbgs() <<
"Range check and latch have IVs different steps!\n");
662 auto *Ty = RangeCheckIV->getType();
663 auto CurrLatchCheckOpt =
665 if (!CurrLatchCheckOpt) {
667 "corresponding to range type: "
672 LoopICmp CurrLatchCheck = *CurrLatchCheckOpt;
677 "Range and latch steps should be of same type!");
679 LLVM_DEBUG(
dbgs() <<
"Range and latch have different step values!\n");
684 return widenICmpRangeCheckIncrementingLoop(CurrLatchCheck, *RangeCheck,
688 return widenICmpRangeCheckDecrementingLoop(CurrLatchCheck, *RangeCheck,
696 for (
auto &
Check : Checks)
698 if (
auto NewRangeCheck = widenICmpRangeCheck(ICI, Expander, Guard)) {
700 Check = *NewRangeCheck;
704bool LoopPredication::widenGuardConditions(
IntrinsicInst *Guard,
713 widenChecks(Checks, WidenedChecks, Expander, Guard);
714 if (WidenedChecks.
empty())
717 TotalWidened += WidenedChecks.
size();
721 Value *AllChecks = Builder.CreateAnd(Checks);
724 if (Opts.loop_predication_insert_assumes_of_predicated_guards_conditions) {
726 AC->registerAssumption(
cast<AssumeInst>(Builder.CreateAssumption(OldCond)));
734bool LoopPredication::widenWidenableBranchGuardConditions(
748 widenChecks(Checks, WidenedChecks, Expander, BI);
749 if (WidenedChecks.
empty())
752 TotalWidened += WidenedChecks.
size();
756 Value *AllChecks = Builder.CreateAnd(Checks);
759 if (Opts.loop_predication_insert_assumes_of_predicated_guards_conditions) {
765 Value *AssumeCond = Builder.CreateAnd(WidenedChecks);
771 PN->addIncoming(
Pred == GuardBB ? AssumeCond : Builder.getTrue(),
Pred);
774 AC->registerAssumption(
779 "Stopped being a guard after transform?");
785std::optional<LoopICmp> LoopPredication::parseLoopLatchICmp() {
801 (TrueDest ==
L->getHeader() || BI->
getSuccessor(1) ==
L->getHeader()) &&
802 "One of the latch's destinations must be the header");
809 auto Result = parseLoopICmp(ICI);
811 LLVM_DEBUG(
dbgs() <<
"Failed to parse the loop latch condition!\n");
815 if (TrueDest !=
L->getHeader())
820 if (!
Result->IV->isAffine()) {
825 const SCEV *Step =
Result->IV->getStepRecurrence(*SE);
826 if (!isSupportedStep(Step)) {
827 LLVM_DEBUG(
dbgs() <<
"Unsupported loop stride(" << *Step <<
")!\n");
843 if (IsUnsupportedPredicate(Step,
Result->Pred)) {
852bool LoopPredication::isLoopProfitableToPredicate() {
853 if (Opts.loop_predication_skip_profitability_checks)
857 LI->getExitEdges(*L, ExitEdges);
860 if (ExitEdges.
size() == 1)
868 auto *LatchBlock =
L->getLoopLatch();
869 assert(LatchBlock &&
"Should have a single latch at this point!");
870 auto *LatchTerm = LatchBlock->getTerminator();
871 assert(LatchTerm->getNumSuccessors() == 2 &&
872 "expected to be an exiting block with 2 succs!");
873 unsigned LatchBrExitIdx =
874 LatchTerm->getSuccessor(0) ==
L->getHeader() ? 1 : 0;
882 auto *LatchExitBlock = LatchTerm->getSuccessor(LatchBrExitIdx);
884 LatchExitBlock->getTerminatingDeoptimizeCall())
892 auto ComputeBranchProbability =
896 unsigned NumSucc =
Term->getNumSuccessors();
900 uint64_t Numerator = 0, Denominator = 0;
902 if (
Term->getSuccessor(i) == ExitBlock)
904 Denominator += Weight;
907 if (Denominator == 0)
911 assert(LatchBlock != ExitingBlock &&
912 "Latch term should always have profile data!");
919 ComputeBranchProbability(LatchBlock, LatchExitBlock);
923 float ScaleFactor = Opts.loop_predication_latch_probability_scale;
924 if (ScaleFactor < 1) {
927 <<
"Ignored user setting for loop-predication-latch-probability-scale: "
928 << Opts.loop_predication_latch_probability_scale <<
"\n");
932 const auto LatchProbabilityThreshold = LatchExitProbability * ScaleFactor;
934 for (
const auto &ExitEdge : ExitEdges) {
936 ComputeBranchProbability(ExitEdge.first, ExitEdge.second);
939 if (ExitingBlockProbability > LatchProbabilityThreshold)
963 if (BB ==
Pred->getSingleSuccessor()) {
985 L->getExitingBlocks(ExitingBlocks);
993 "We should only have known counts for exiting blocks that "
997 if (ExitCounts.
size() < 2)
1028 L->getExitingBlocks(ExitingBlocks);
1030 if (ExitingBlocks.
empty())
1033 auto *Latch =
L->getLoopLatch();
1041 const SCEV *LatchEC = SE->getExitCount(L, Latch);
1051 bool ChangedLoop =
false;
1053 for (
auto *ExitingBB : ExitingBlocks) {
1054 if (LI->getLoopFor(ExitingBB) != L)
1063 assert(WC->hasOneUse() &&
"Not appropriate widenable branch!");
1064 WC->user_back()->replaceUsesOfWith(
1085 !SE->isLoopInvariant(MinEC, L) ||
1086 !
Rewriter.isSafeToExpandAt(MinEC, IP))
1092 bool InvalidateLoop =
false;
1093 Value *MinECV =
nullptr;
1094 for (
BasicBlock *ExitingBB : ExitingBlocks) {
1098 if (LI->getLoopFor(ExitingBB) != L)
1110 const SCEV *ExitCount = SE->getExitCount(L, ExitingBB);
1113 !
Rewriter.isSafeToExpandAt(ExitCount, WidenableBR))
1116 const bool ExitIfTrue = !
L->contains(*
succ_begin(ExitingBB));
1131 MinECV =
Rewriter.expandCodeFor(MinEC);
1135 ECV =
B.CreateZExt(ECV, WiderTy);
1136 RHS =
B.CreateZExt(
RHS, WiderTy);
1138 assert(!Latch || DT->dominates(ExitingBB, Latch));
1143 NewCond =
B.CreateFreeze(NewCond);
1149 InvalidateLoop =
true;
1163bool LoopPredication::runOnLoop(
Loop *
Loop) {
1169 Module *
M =
L->getHeader()->getModule();
1174 bool HasIntrinsicGuards = GuardDecl && !GuardDecl->use_empty();
1176 M, Intrinsic::experimental_widenable_condition);
1177 bool HasWidenableConditions =
1178 Opts.loop_predication_predicate_widenable_branches_to_deopt && WCDecl &&
1179 !WCDecl->use_empty();
1180 if (!HasIntrinsicGuards && !HasWidenableConditions)
1183 DL = &
M->getDataLayout();
1185 Preheader =
L->getLoopPreheader();
1189 auto LatchCheckOpt = parseLoopLatchICmp();
1192 LatchCheck = *LatchCheckOpt;
1197 if (!isLoopProfitableToPredicate()) {
1205 for (
const auto BB :
L->blocks()) {
1209 if (Opts.loop_predication_predicate_widenable_branches_to_deopt &&
1217 for (
auto *Guard : Guards)
1218 Changed |= widenGuardConditions(Guard, Expander);
1219 for (
auto *Guard : GuardsAsWidenableBranches)
1220 Changed |= widenWidenableBranchGuardConditions(Guard, Expander);
1221 Changed |= predicateLoopExits(L, Expander);
1224 MSSAU->getMemorySSA()->verifyMemorySSA();
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
Module.h This file contains the declarations for the Module class.
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
static CondBrInst * FindWidenableTerminatorAboveLoop(Loop *L, LoopInfo &LI)
If we can (cheaply) find a widenable branch which controls entry into the loop, return it.
static void normalizePredicate(ScalarEvolution *SE, Loop *L, LoopICmp &RC)
static std::optional< LoopICmp > generateLoopLatchCheck(const ScalarOptions &Opts, const DataLayout &DL, ScalarEvolution &SE, const LoopICmp LatchCheck, Type *RangeCheckType)
static const SCEV * getMinAnalyzeableBackedgeTakenCount(ScalarEvolution &SE, DominatorTree &DT, Loop *L)
Return the minimum of all analyzeable exit counts.
static bool isSafeToTruncateWideIVType(const ScalarOptions &Opts, const DataLayout &DL, ScalarEvolution &SE, const LoopICmp LatchCheck, Type *RangeCheckType)
This file exposes an interface to building/using memory SSA to walk memory instructions using a use/d...
uint64_t IntrinsicInst * II
This file contains the declarations for profiling metadata utility functions.
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
virt reg Virtual Register Rewriter
static const uint32_t IV[8]
Represent a constant reference to an array (0 or more elements consecutively in memory),...
LLVM Basic Block Representation.
LLVM_ABI const_iterator getFirstInsertionPt() const
Returns an iterator to the first instruction in this block that is suitable for inserting a non-PHI i...
LLVM_ABI const BasicBlock * getSinglePredecessor() const
Return the predecessor of this block if it has a single predecessor block.
LLVM_ABI const BasicBlock * getUniquePredecessor() const
Return the predecessor of this block if it has a unique predecessor block.
InstListType::iterator iterator
Instruction iterators...
LLVM_ABI const CallInst * getPostdominatingDeoptimizeCall() const
Returns the call instruction calling @llvm.experimental.deoptimize that is present either in current ...
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction; assumes that the block is well-formed.
static LLVM_ABI BranchProbability getBranchProbability(uint64_t Numerator, uint64_t Denominator)
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_UGT
unsigned greater than
@ ICMP_SGT
signed greater than
@ 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 getInversePredicate() const
For example, EQ -> NE, UGT -> ULE, SLT -> SGE, OEQ -> UNE, UGT -> OLE, OLT -> UGE,...
Predicate getPredicate() const
Return the predicate for this instruction.
Predicate getFlippedStrictnessPredicate() const
For predicate of kind "is X or equal to 0" returns the predicate "is X".
Conditional Branch instruction.
void setCondition(Value *V)
Value * getCondition() const
BasicBlock * getSuccessor(unsigned i) const
static LLVM_ABI ConstantInt * getTrue(LLVMContext &Context)
A parsed version of the target data layout string in and methods for querying it.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
LLVM_ABI bool dominates(const BasicBlock *BB, const Use &U) const
Return true if the (end of the) basic block BB dominates the use U.
This instruction compares its operands according to the predicate given to the constructor.
static bool isEquality(Predicate P)
Return true if this predicate is either EQ or NE.
Value * CreateFreeze(Value *V, const Twine &Name="")
Value * CreateICmp(CmpInst::Predicate P, Value *LHS, Value *RHS, const Twine &Name="", bool HasSameSign=false)
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
A wrapper class for inspecting calls to intrinsic functions.
This class provides an interface for updating the loop pass manager based on mutations to the loop ne...
LLVM_ABI PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM, LoopStandardAnalysisResults &AR, LPMUpdater &U)
Represents a single loop in the control flow graph.
An analysis that produces MemorySSA for a function.
A Module instance is used to store all the information related to an LLVM module.
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.
This node represents a polynomial recurrence on the trip count of the specified loop.
LLVM_ABI const SCEVAddRecExpr * getPostIncExpr(ScalarEvolution &SE) const
Return an expression representing the value of this expression one iteration of the loop ahead.
const Loop * getLoop() const
SCEVUse getStepRecurrence(ScalarEvolution &SE) const
Constructs and returns the recurrence indicating how much this expression steps by.
This class uses information about analyze scalars to rewrite expressions in canonical form.
LLVM_ABI bool isSafeToExpandAt(const SCEV *S, const Instruction *InsertionPoint) const
Return true if the given expression is safe to expand in the sense that all materialized values are d...
LLVM_ABI Value * expandCodeFor(SCEVUse SH, Type *Ty, BasicBlock::iterator I)
Insert code to directly compute the specified SCEV expression into the program.
This means that we are dealing with an entirely unknown SCEV value, and only represent it as its LLVM...
This class represents an analyzed expression in the program.
LLVM_ABI bool isOne() const
Return true if the expression is a constant one.
LLVM_ABI bool isAllOnesValue() const
Return true if the expression is a constant all-ones value.
Type * getType() const
Return the LLVM type of this SCEV expression.
The main scalar evolution driver.
LLVM_ABI const SCEV * getTruncateExpr(SCEVUse Op, Type *Ty, unsigned Depth=0)
LLVM_ABI const SCEV * getUMinFromMismatchedTypes(const SCEV *LHS, const SCEV *RHS, bool Sequential=false)
Promote the operands to the wider of the types using zero-extension, and then perform a umin operatio...
LLVM_ABI std::optional< MonotonicPredicateType > getMonotonicPredicateType(const SCEVAddRecExpr *LHS, ICmpInst::Predicate Pred)
If, for all loop invariant X, the predicate "LHS `Pred` X" is monotonically increasing or decreasing,...
LLVM_ABI const SCEV * getCouldNotCompute()
LLVM_ABI const SCEV * getExitCount(const Loop *L, const BasicBlock *ExitingBlock, ExitCountKind Kind=Exact)
Return the number of times the backedge executes before the given exit would be taken; if not exactly...
LLVM_ABI bool isKnownPredicate(CmpPredicate Pred, SCEVUse LHS, SCEVUse RHS, unsigned Depth=0)
Test if the given expression is known to satisfy the condition described by Pred, LHS,...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
The instances of the Type class are immutable: once they are created, they are never changed.
bool isPointerTy() const
True if this is an instance of PointerType.
A Use represents the edge between a Value definition and its users.
void setOperand(unsigned i, Value *Val)
Value * getOperand(unsigned i) const
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
LLVMContext & getContext() const
All values hold a context through their type.
LLVM_ABI void dump() const
Support for debugging, callable in GDB: V->dump()
const ParentTy * getParent() const
Abstract Attribute helper functions.
@ BasicBlock
Various leaf nodes.
LLVM_ABI Function * getDeclarationIfExists(const Module *M, ID id)
Look up the Function declaration of the intrinsic id in the Module M and return it if it exists.
friend class Instruction
Iterator for Instructions in a `BasicBlock.
This is an optimization pass for GlobalISel generic memory operations.
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
LLVM_ABI bool RecursivelyDeleteTriviallyDeadInstructions(Value *V, const TargetLibraryInfo *TLI=nullptr, MemorySSAUpdater *MSSAU=nullptr, std::function< void(Value *)> AboutToDeleteCallback=std::function< void(Value *)>())
If the specified value is a trivially dead instruction, delete it.
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are tuples (A, B,...
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
SCEVUseT< const SCEV * > SCEVUse
LLVM_ABI Value * extractWidenableCondition(const User *U)
auto pred_size(const MachineBasicBlock *BB)
const ScalarOptions & getScalarOptions(const LLVMContext &C)
LLVM_ABI void parseWidenableGuard(const User *U, llvm::SmallVectorImpl< Value * > &Checks)
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
AnalysisManager< Loop, LoopStandardAnalysisResults & > LoopAnalysisManager
The loop analysis manager.
LLVM_ABI bool isGuard(const User *U)
Returns true iff U has semantics of a guard expressed in a form of call of llvm.experimental....
LLVM_ABI MDNode * getValidBranchWeightMDNode(const Instruction &I)
Get the valid branch weights metadata node.
bool isModSet(const ModRefInfo MRI)
LLVM_ABI bool hasValidBranchWeightMD(const Instruction &I)
Checks if an instructions has valid Branch Weight Metadata.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_ABI bool VerifyMemorySSA
Enables verification of MemorySSA.
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
RNSuccIterator< NodeRef, BlockT, RegionT > succ_begin(NodeRef Node)
LLVM_ABI bool isWidenableBranch(const User *U)
Returns true iff U is a widenable branch (that is, extractWidenableCondition returns widenable condit...
LLVM_ABI bool isGuardAsWidenableBranch(const User *U)
Returns true iff U has semantics of a guard expressed in a form of a widenable conditional branch to ...
DWARFExpression::Operation Op
ArrayRef(const T &OneElt) -> ArrayRef< T >
LLVM_ABI bool extractBranchWeights(const MDNode *ProfileData, SmallVectorImpl< uint32_t > &Weights)
Extract branch weights from MD_prof metadata.
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.
auto predecessors(const MachineBasicBlock *BB)
LLVM_ABI void widenWidenableBranch(CondBrInst *WidenableBR, Value *NewCond)
Given a branch we know is widenable (defined per Analysis/GuardUtils.h), widen it such that condition...
AAResults AliasAnalysis
Temporary typedef for legacy code that uses a generic AliasAnalysis pointer or reference.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
The adaptor from a function pass to a loop pass computes these analyses and makes them available to t...