205#define DEBUG_TYPE "loop-predication"
207STATISTIC(TotalConsidered,
"Number of guards considered");
221 : Pred(Pred),
IV(
IV), Limit(Limit) {}
222 LoopICmp() =
default;
224 dbgs() <<
"LoopICmp Pred = " << Pred <<
", IV = " << *IV
225 <<
", Limit = " << *Limit <<
"\n";
229class LoopPredication {
230 const ScalarOptions &Opts;
235 MemorySSAUpdater *MSSAU;
238 const DataLayout *DL;
242 bool isSupportedStep(
const SCEV* Step);
243 std::optional<LoopICmp> parseLoopICmp(ICmpInst *ICI);
244 std::optional<LoopICmp> parseLoopLatchICmp();
255 Instruction *findInsertPt(
const SCEVExpander &Expander, Instruction *User,
261 bool isLoopInvariantValue(
const SCEV* S);
263 Value *expandCheck(SCEVExpander &Expander, Instruction *Guard,
264 ICmpInst::Predicate Pred,
const SCEV *
LHS,
267 std::optional<Value *> widenICmpRangeCheck(ICmpInst *ICI,
268 SCEVExpander &Expander,
270 std::optional<Value *>
271 widenICmpRangeCheckIncrementingLoop(LoopICmp LatchCheck, LoopICmp RangeCheck,
272 SCEVExpander &Expander,
274 std::optional<Value *>
275 widenICmpRangeCheckDecrementingLoop(LoopICmp LatchCheck, LoopICmp RangeCheck,
276 SCEVExpander &Expander,
278 void widenChecks(SmallVectorImpl<Value *> &Checks,
279 SmallVectorImpl<Value *> &WidenedChecks,
280 SCEVExpander &Expander, Instruction *Guard);
281 bool widenGuardConditions(IntrinsicInst *
II, SCEVExpander &Expander);
282 bool widenWidenableBranchGuardConditions(CondBrInst *Guard,
283 SCEVExpander &Expander);
288 bool isLoopProfitableToPredicate();
290 bool predicateLoopExits(
Loop *L, SCEVExpander &
Rewriter);
293 LoopPredication(
AliasAnalysis *AA, DominatorTree *DT, ScalarEvolution *SE,
294 LoopInfo *LI, MemorySSAUpdater *MSSAU)
295 : Opts(ScalarOptions::
Global), AA(AA), DT(DT), SE(SE), LI(LI),
297 bool runOnLoop(
Loop *L);
305 std::unique_ptr<MemorySSAUpdater> MSSAU;
307 MSSAU = std::make_unique<MemorySSAUpdater>(AR.
MSSA);
308 LoopPredication LP(&AR.
AA, &AR.
DT, &AR.
SE, &AR.
LI,
309 MSSAU ? MSSAU.get() :
nullptr);
310 if (!LP.runOnLoop(&L))
319std::optional<LoopICmp> LoopPredication::parseLoopICmp(
ICmpInst *ICI) {
324 const SCEV *LHSS = SE->getSCEV(LHS);
327 const SCEV *RHSS = SE->getSCEV(RHS);
332 if (SE->isLoopInvariant(LHSS, L)) {
342 return LoopICmp(Pred, AR, RHSS);
350 assert(Ty ==
RHS->
getType() &&
"expandCheck operands have different types?");
352 if (SE->isLoopInvariant(
LHS, L) && SE->isLoopInvariant(
RHS, L)) {
354 if (SE->isLoopEntryGuardedByCond(L, Pred,
LHS,
RHS))
355 return Builder.getTrue();
358 return Builder.getFalse();
365 IRBuilder<> Builder(findInsertPt(Guard, {LHSV, RHSV}));
385 const LoopICmp LatchCheck,
386 Type *RangeCheckType) {
387 if (!Opts.loop_predication_enable_iv_truncation)
389 assert(
DL.getTypeSizeInBits(LatchCheck.IV->
getType()).getFixedValue() >
390 DL.getTypeSizeInBits(RangeCheckType).getFixedValue() &&
391 "Expected latch check IV type to be larger than range check operand "
397 if (!Limit || !Start)
409 auto RangeCheckTypeBitSize =
410 DL.getTypeSizeInBits(RangeCheckType).getFixedValue();
411 return Start->getAPInt().getActiveBits() < RangeCheckTypeBitSize &&
412 Limit->getAPInt().getActiveBits() < RangeCheckTypeBitSize;
420 const LoopICmp LatchCheck,
421 Type *RangeCheckType) {
423 auto *LatchType = LatchCheck.IV->
getType();
424 if (RangeCheckType == LatchType)
427 if (
DL.getTypeSizeInBits(LatchType).getFixedValue() <
428 DL.getTypeSizeInBits(RangeCheckType).getFixedValue())
434 LoopICmp NewLatchCheck;
435 NewLatchCheck.Pred = LatchCheck.Pred;
438 if (!NewLatchCheck.IV)
440 NewLatchCheck.Limit = SE.
getTruncateExpr(LatchCheck.Limit, RangeCheckType);
442 <<
"can be represented as range check type:"
443 << *RangeCheckType <<
"\n");
444 LLVM_DEBUG(
dbgs() <<
"LatchCheck.IV: " << *NewLatchCheck.IV <<
"\n");
445 LLVM_DEBUG(
dbgs() <<
"LatchCheck.Limit: " << *NewLatchCheck.Limit <<
"\n");
446 return NewLatchCheck;
449bool LoopPredication::isSupportedStep(
const SCEV* Step) {
451 Opts.loop_predication_enable_count_down_loop);
457 if (!
L->isLoopInvariant(
Op))
459 return Preheader->getTerminator();
469 if (!SE->isLoopInvariant(
Op, L) ||
472 return Preheader->getTerminator();
475bool LoopPredication::isLoopInvariantValue(
const SCEV* S) {
495 if (SE->isLoopInvariant(S, L))
505 if (LI->isUnordered() &&
L->hasLoopInvariantOperands(LI))
506 if (!
isModSet(
AA->getModRefInfoMask(LI->getOperand(0))) ||
507 LI->hasMetadata(LLVMContext::MD_invariant_load))
512std::optional<Value *> LoopPredication::widenICmpRangeCheckIncrementingLoop(
513 LoopICmp LatchCheck, LoopICmp RangeCheck,
SCEVExpander &Expander,
515 auto *Ty = RangeCheck.IV->
getType();
523 const SCEV *GuardLimit = RangeCheck.Limit;
525 const SCEV *LatchLimit = LatchCheck.Limit;
529 if (!isLoopInvariantValue(GuardStart) ||
530 !isLoopInvariantValue(GuardLimit) ||
531 !isLoopInvariantValue(LatchStart) ||
532 !isLoopInvariantValue(LatchLimit)) {
544 SE->getAddExpr(SE->getMinusSCEV(GuardLimit, GuardStart),
545 SE->getMinusSCEV(LatchStart, SE->getOne(Ty)));
546 auto LimitCheckPred =
554 expandCheck(Expander, Guard, LimitCheckPred, LatchLimit,
RHS);
555 auto *FirstIterationCheck = expandCheck(Expander, Guard, RangeCheck.Pred,
556 GuardStart, GuardLimit);
557 IRBuilder<> Builder(findInsertPt(Guard, {FirstIterationCheck, LimitCheck}));
559 Builder.CreateAnd(FirstIterationCheck, LimitCheck));
562std::optional<Value *> LoopPredication::widenICmpRangeCheckDecrementingLoop(
563 LoopICmp LatchCheck, LoopICmp RangeCheck,
SCEVExpander &Expander,
565 auto *Ty = RangeCheck.IV->
getType();
567 const SCEV *GuardLimit = RangeCheck.Limit;
569 const SCEV *LatchLimit = LatchCheck.Limit;
573 if (!isLoopInvariantValue(GuardStart) ||
574 !isLoopInvariantValue(GuardLimit) ||
575 !isLoopInvariantValue(LatchStart) ||
576 !isLoopInvariantValue(LatchLimit)) {
588 if (RangeCheck.IV != PostDecLatchCheckIV) {
590 << *PostDecLatchCheckIV
591 <<
" and RangeCheckIV: " << *RangeCheck.IV <<
"\n");
599 auto LimitCheckPred =
601 auto *FirstIterationCheck = expandCheck(Expander, Guard,
603 GuardStart, GuardLimit);
604 auto *LimitCheck = expandCheck(Expander, Guard, LimitCheckPred, LatchLimit,
606 IRBuilder<> Builder(findInsertPt(Guard, {FirstIterationCheck, LimitCheck}));
608 Builder.CreateAnd(FirstIterationCheck, LimitCheck));
625std::optional<Value *>
635 auto RangeCheck = parseLoopICmp(ICI);
637 LLVM_DEBUG(
dbgs() <<
"Failed to parse the loop latch condition!\n");
644 << RangeCheck->Pred <<
")!\n");
647 auto *RangeCheckIV = RangeCheck->IV;
648 if (!RangeCheckIV->isAffine()) {
652 const SCEV *Step = RangeCheckIV->getStepRecurrence(*SE);
655 if (!isSupportedStep(Step)) {
656 LLVM_DEBUG(
dbgs() <<
"Range check and latch have IVs different steps!\n");
659 auto *Ty = RangeCheckIV->getType();
660 auto CurrLatchCheckOpt =
662 if (!CurrLatchCheckOpt) {
664 "corresponding to range type: "
669 LoopICmp CurrLatchCheck = *CurrLatchCheckOpt;
674 "Range and latch steps should be of same type!");
676 LLVM_DEBUG(
dbgs() <<
"Range and latch have different step values!\n");
681 return widenICmpRangeCheckIncrementingLoop(CurrLatchCheck, *RangeCheck,
685 return widenICmpRangeCheckDecrementingLoop(CurrLatchCheck, *RangeCheck,
693 for (
auto &
Check : Checks)
695 if (
auto NewRangeCheck = widenICmpRangeCheck(ICI, Expander, Guard)) {
697 Check = *NewRangeCheck;
701bool LoopPredication::widenGuardConditions(
IntrinsicInst *Guard,
710 widenChecks(Checks, WidenedChecks, Expander, Guard);
711 if (WidenedChecks.
empty())
714 TotalWidened += WidenedChecks.
size();
718 Value *AllChecks = Builder.CreateAnd(Checks);
721 if (Opts.loop_predication_insert_assumes_of_predicated_guards_conditions) {
723 Builder.CreateAssumption(OldCond);
731bool LoopPredication::widenWidenableBranchGuardConditions(
745 widenChecks(Checks, WidenedChecks, Expander, BI);
746 if (WidenedChecks.
empty())
749 TotalWidened += WidenedChecks.
size();
753 Value *AllChecks = Builder.CreateAnd(Checks);
756 if (Opts.loop_predication_insert_assumes_of_predicated_guards_conditions) {
762 Value *AssumeCond = Builder.CreateAnd(WidenedChecks);
768 PN->addIncoming(Pred == GuardBB ? AssumeCond : Builder.getTrue(), Pred);
771 Builder.CreateAssumption(AssumeCond);
775 "Stopped being a guard after transform?");
781std::optional<LoopICmp> LoopPredication::parseLoopLatchICmp() {
797 (TrueDest ==
L->getHeader() || BI->
getSuccessor(1) ==
L->getHeader()) &&
798 "One of the latch's destinations must be the header");
805 auto Result = parseLoopICmp(ICI);
807 LLVM_DEBUG(
dbgs() <<
"Failed to parse the loop latch condition!\n");
811 if (TrueDest !=
L->getHeader())
816 if (!
Result->IV->isAffine()) {
821 const SCEV *Step =
Result->IV->getStepRecurrence(*SE);
822 if (!isSupportedStep(Step)) {
823 LLVM_DEBUG(
dbgs() <<
"Unsupported loop stride(" << *Step <<
")!\n");
839 if (IsUnsupportedPredicate(Step,
Result->Pred)) {
848bool LoopPredication::isLoopProfitableToPredicate() {
849 if (Opts.loop_predication_skip_profitability_checks)
853 LI->getExitEdges(*L, ExitEdges);
856 if (ExitEdges.
size() == 1)
864 auto *LatchBlock =
L->getLoopLatch();
865 assert(LatchBlock &&
"Should have a single latch at this point!");
866 auto *LatchTerm = LatchBlock->getTerminator();
867 assert(LatchTerm->getNumSuccessors() == 2 &&
868 "expected to be an exiting block with 2 succs!");
869 unsigned LatchBrExitIdx =
870 LatchTerm->getSuccessor(0) ==
L->getHeader() ? 1 : 0;
878 auto *LatchExitBlock = LatchTerm->getSuccessor(LatchBrExitIdx);
880 LatchExitBlock->getTerminatingDeoptimizeCall())
888 auto ComputeBranchProbability =
892 unsigned NumSucc =
Term->getNumSuccessors();
896 uint64_t Numerator = 0, Denominator = 0;
898 if (
Term->getSuccessor(i) == ExitBlock)
900 Denominator += Weight;
903 if (Denominator == 0)
907 assert(LatchBlock != ExitingBlock &&
908 "Latch term should always have profile data!");
915 ComputeBranchProbability(LatchBlock, LatchExitBlock);
919 float ScaleFactor = Opts.loop_predication_latch_probability_scale;
920 if (ScaleFactor < 1) {
923 <<
"Ignored user setting for loop-predication-latch-probability-scale: "
924 << Opts.loop_predication_latch_probability_scale <<
"\n");
928 const auto LatchProbabilityThreshold = LatchExitProbability * ScaleFactor;
930 for (
const auto &ExitEdge : ExitEdges) {
932 ComputeBranchProbability(ExitEdge.first, ExitEdge.second);
935 if (ExitingBlockProbability > LatchProbabilityThreshold)
981 L->getExitingBlocks(ExitingBlocks);
989 "We should only have known counts for exiting blocks that "
993 if (ExitCounts.
size() < 2)
1024 L->getExitingBlocks(ExitingBlocks);
1026 if (ExitingBlocks.
empty())
1029 auto *Latch =
L->getLoopLatch();
1037 const SCEV *LatchEC = SE->getExitCount(L, Latch);
1047 bool ChangedLoop =
false;
1049 for (
auto *ExitingBB : ExitingBlocks) {
1050 if (LI->getLoopFor(ExitingBB) != L)
1059 assert(WC->hasOneUse() &&
"Not appropriate widenable branch!");
1060 WC->user_back()->replaceUsesOfWith(
1081 !SE->isLoopInvariant(MinEC, L) ||
1082 !
Rewriter.isSafeToExpandAt(MinEC, IP))
1088 bool InvalidateLoop =
false;
1089 Value *MinECV =
nullptr;
1090 for (
BasicBlock *ExitingBB : ExitingBlocks) {
1094 if (LI->getLoopFor(ExitingBB) != L)
1106 const SCEV *ExitCount = SE->getExitCount(L, ExitingBB);
1109 !
Rewriter.isSafeToExpandAt(ExitCount, WidenableBR))
1112 const bool ExitIfTrue = !
L->contains(*
succ_begin(ExitingBB));
1127 MinECV =
Rewriter.expandCodeFor(MinEC);
1131 ECV =
B.CreateZExt(ECV, WiderTy);
1132 RHS =
B.CreateZExt(
RHS, WiderTy);
1134 assert(!Latch || DT->dominates(ExitingBB, Latch));
1139 NewCond =
B.CreateFreeze(NewCond);
1145 InvalidateLoop =
true;
1159bool LoopPredication::runOnLoop(
Loop *
Loop) {
1165 Module *
M =
L->getHeader()->getModule();
1170 bool HasIntrinsicGuards = GuardDecl && !GuardDecl->use_empty();
1172 M, Intrinsic::experimental_widenable_condition);
1173 bool HasWidenableConditions =
1174 Opts.loop_predication_predicate_widenable_branches_to_deopt && WCDecl &&
1175 !WCDecl->use_empty();
1176 if (!HasIntrinsicGuards && !HasWidenableConditions)
1179 DL = &
M->getDataLayout();
1181 Preheader =
L->getLoopPreheader();
1185 auto LatchCheckOpt = parseLoopLatchICmp();
1188 LatchCheck = *LatchCheckOpt;
1193 if (!isLoopProfitableToPredicate()) {
1201 for (
const auto BB :
L->blocks()) {
1205 if (Opts.loop_predication_predicate_widenable_branches_to_deopt &&
1213 for (
auto *Guard : Guards)
1214 Changed |= widenGuardConditions(Guard, Expander);
1215 for (
auto *Guard : GuardsAsWidenableBranches)
1216 Changed |= widenWidenableBranchGuardConditions(Guard, Expander);
1217 Changed |= predicateLoopExits(L, Expander);
1220 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.
LLVM_ABI const BasicBlock * getSingleSuccessor() const
Return the successor of this block if it has a single successor.
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="")
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)
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.
LLVM_ABI Value * extractWidenableCondition(const User *U)
auto pred_size(const MachineBasicBlock *BB)
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.
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)
@ Global
Append to llvm.global_dtors.
LLVM_ABI bool isWidenableBranch(const User *U)
Returns true iff U is a widenable branch (that is, extractWidenableCondition returns widenable condit...
LLVM_ABI bool VerifyMemorySSA
Enables verification of MemorySSA.
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.
SCEVUseT< const SCEV * > SCEVUse
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...