LLVM 24.0.0git
LoopUtils.h
Go to the documentation of this file.
1//===- llvm/Transforms/Utils/LoopUtils.h - Loop utilities -------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file defines some loop transformation utilities.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_TRANSFORMS_UTILS_LOOPUTILS_H
14#define LLVM_TRANSFORMS_UTILS_LOOPUTILS_H
15
19
20namespace llvm {
21
22template <typename T> class DomTreeNodeBase;
24class AssumptionCache;
25class StringRef;
26class AnalysisUsage;
28class AAResults;
29class BasicBlock;
31class IRBuilderBase;
32class Loop;
33class LoopInfo;
34class MemoryAccess;
35class MemorySSA;
38struct PointerDiffInfo;
40class ScalarEvolution;
41class SCEV;
42class SCEVExpander;
43class SCEVAddRecExpr;
45class LPPassManager;
46class Instruction;
50
51typedef std::pair<const RuntimeCheckingPtrGroup *,
54
55template <typename T, unsigned N> class SmallSetVector;
56template <typename T, unsigned N> class SmallPriorityWorklist;
57
59 LoopInfo *LI,
60 MemorySSAUpdater *MSSAU,
61 bool PreserveLCSSA);
62
63/// Ensure that all exit blocks of the loop are dedicated exits.
64///
65/// For any loop exit block with non-loop predecessors, we split the loop
66/// predecessors to use a dedicated loop exit block. We update the dominator
67/// tree and loop info if provided, and will preserve LCSSA if requested.
69 MemorySSAUpdater *MSSAU,
70 bool PreserveLCSSA);
71
72/// Ensures LCSSA form for every instruction from the Worklist in the scope of
73/// innermost containing loop.
74///
75/// For the given instruction which have uses outside of the loop, an LCSSA PHI
76/// node is inserted and the uses outside the loop are rewritten to use this
77/// node.
78///
79/// LoopInfo and DominatorTree are required and, since the routine makes no
80/// changes to CFG, preserved.
81///
82/// Returns true if any modifications are made.
83///
84/// This function may introduce unused PHI nodes. If \p PHIsToRemove is not
85/// nullptr, those are added to it (before removing, the caller has to check if
86/// they still do not have any uses). Otherwise the PHIs are directly removed.
87///
88/// If \p InsertedPHIs is not nullptr, inserted phis will be added to this
89/// vector.
90LLVM_ABI bool
92 const DominatorTree &DT, const LoopInfo &LI,
94 SmallVectorImpl<PHINode *> *PHIsToRemove = nullptr,
95 SmallVectorImpl<PHINode *> *InsertedPHIs = nullptr);
96
97/// Put loop into LCSSA form.
98///
99/// Looks at all instructions in the loop which have uses outside of the
100/// current loop. For each, an LCSSA PHI node is inserted and the uses outside
101/// the loop are rewritten to use this node. Sub-loops must be in LCSSA form
102/// already.
103///
104/// LoopInfo and DominatorTree are required and preserved.
105///
106/// If ScalarEvolution is passed in, it will be preserved.
107///
108/// Returns true if any modifications are made to the loop.
109LLVM_ABI bool formLCSSA(Loop &L, const DominatorTree &DT, const LoopInfo *LI,
110 ScalarEvolution *SE);
111
112/// Put a loop nest into LCSSA form.
113///
114/// This recursively forms LCSSA for a loop nest.
115///
116/// LoopInfo and DominatorTree are required and preserved.
117///
118/// If ScalarEvolution is passed in, it will be preserved.
119///
120/// Returns true if any modifications are made to the loop.
122 const LoopInfo *LI, ScalarEvolution *SE);
123
124/// Flags controlling how much is checked when sinking or hoisting
125/// instructions. The number of memory access in the loop (and whether there
126/// are too many) is determined in the constructors when using MemorySSA.
128public:
129 // Explicitly set limits.
132 bool IsSink, Loop &L, MemorySSA &MSSA);
133 // Use default limits.
135
136 void setIsSink(bool B) { IsSink = B; }
137 bool getIsSink() { return IsSink; }
141
142protected:
143 bool NoOfMemAccTooLarge = false;
144 unsigned LicmMssaOptCounter = 0;
147 bool IsSink;
148};
149
150/// Dependencies required to check legality of sinking and hoisting.
158
159/// Dependencies required by LICM transforms.
168
169/// Walk the specified region of the CFG (defined by all blocks
170/// dominated by the specified block, and that are in the current loop) in
171/// reverse depth first order w.r.t the DominatorTree. This allows us to visit
172/// uses before definitions, allowing us to sink a loop body in one pass without
173/// iteration. Takes DomTreeNode, LICMDependencies, Loop and AliasSet
174/// information for all instructions of the loop as arguments. Diagnostics is
175/// emitted via LICMDependencies::ORE. It returns changed status. \p CurLoop is
176/// a loop to do sinking on. \p OutermostLoop is used only when this function is
177/// called by \p sinkRegionForLoopNest.
178LLVM_ABI bool sinkRegion(DomTreeNode *, const LICMDependencies &, Loop *CurLoop,
180 Loop *OutermostLoop = nullptr);
181
182/// Call sinkRegion on loops contained within the specified loop
183/// in order from innermost to outermost.
186
187/// Walk the specified region of the CFG (defined by all blocks
188/// dominated by the specified block, and that are in the current loop) in depth
189/// first order w.r.t the DominatorTree. This allows us to visit definitions
190/// before uses, allowing us to hoist a loop body in one pass without iteration.
191/// Takes DomTreeNode, LICMDependencies, Loop and AliasSet information for all
192/// instructions of the loop as arguments.
193/// Diagnostics is emitted via LICMDependencies::ORE. It returns changed status.
194/// \p AllowSpeculation is whether values should be hoisted even if they are not
195/// guaranteed to execute in the loop, but are safe to speculatively execute.
197 SinkAndHoistLICMFlags &, bool LoopNestMode,
198 bool AllowSpeculation);
199
200/// Return true if the induction variable \p IV in a Loop whose latch is
201/// \p LatchBlock would become dead if the exit test \p Cond were removed.
202/// Conservatively returns false if analysis is insufficient.
204
205/// This function deletes dead loops. The caller of this function needs to
206/// guarantee that the loop is infact dead.
207/// The function requires a bunch or prerequisites to be present:
208/// - The loop needs to be in LCSSA form
209/// - The loop needs to have a Preheader
210/// - A unique dedicated exit block must exist
211///
212/// This also updates the relevant analysis information in \p DT, \p SE, \p LI
213/// and \p MSSA if pointers to those are provided.
214/// It also updates the loop PM if an updater struct is provided.
215
217 LoopInfo *LI, MemorySSA *MSSA = nullptr);
218
219/// Remove the backedge of the specified loop. Handles loop nests and general
220/// loop structures subject to the precondition that the loop has no parent
221/// loop and has a single latch block. Preserves all listed analyses.
223 LoopInfo &LI, MemorySSA *MSSA);
224
225/// Try to promote memory values to scalars by sinking stores out of
226/// the loop and moving loads to before the loop. We do this by looping over
227/// the stores in the loop, looking for stores to Must pointers which are
228/// loop invariant. It takes a set of must-alias values, Loop exit blocks
229/// vector, loop exit blocks insertion point vector, PredIteratorCache,
230/// LICMDependencies, Loop and AliasSet information for all instructions
231/// of the loop as arguments.
232/// Diagnostics is emitted via LICMDependencies::ORE. It returns changed status.
233/// \p AllowSpeculation is whether values should be hoisted even if they are not
234/// guaranteed to execute in the loop, but are safe to speculatively execute.
239 bool AllowSpeculation, bool HasReadsOutsideSet);
240
241/// Does a BFS from a given node to all of its children inside a given loop.
242/// The returned vector of basic blocks includes the starting point.
245
246/// Returns the instructions that use values defined in the loop.
248
249/// Find a combination of metadata ("llvm.loop.vectorize.width" and
250/// "llvm.loop.vectorize.scalable.enable") for a loop and use it to construct a
251/// ElementCount. If scalable.enable is present the count is scalable; if
252/// scalable.disable is present or the tag is absent, it is fixed-width. If the
253/// metadata "llvm.loop.vectorize.width" cannot be found then std::nullopt is
254/// returned.
255LLVM_ABI std::optional<ElementCount>
257
258/// Create a new loop identifier for a loop created from a loop transformation.
259///
260/// @param OrigLoopID The loop ID of the loop before the transformation.
261/// @param FollowupAttrs List of attribute names that contain attributes to be
262/// added to the new loop ID.
263/// @param InheritOptionsAttrsPrefix Selects which attributes should be inherited
264/// from the original loop. The following values
265/// are considered:
266/// nullptr : Inherit all attributes from @p OrigLoopID.
267/// "" : Do not inherit any attribute from @p OrigLoopID; only use
268/// those specified by a followup attribute.
269/// "<prefix>": Inherit all attributes except those which start with
270/// <prefix>; commonly used to remove metadata for the
271/// applied transformation.
272/// @param AlwaysNew If true, do not try to reuse OrigLoopID and never return
273/// std::nullopt.
274///
275/// @return The loop ID for the after-transformation loop. The following values
276/// can be returned:
277/// std::nullopt : No followup attribute was found; it is up to the
278/// transformation to choose attributes that make sense.
279/// @p OrigLoopID: The original identifier can be reused.
280/// nullptr : The new loop has no attributes.
281/// MDNode* : A new unique loop identifier.
282LLVM_ABI std::optional<MDNode *>
283makeFollowupLoopID(MDNode *OrigLoopID, ArrayRef<StringRef> FollowupAttrs,
284 const char *InheritOptionsAttrsPrefix = "",
285 bool AlwaysNew = false);
286
287/// Look for the loop attribute that disables all transformation heuristic.
289
290/// Look for the loop attribute that disables the LICM transformation heuristics.
292
293/// The mode sets how eager a transformation should be applied.
295 /// The pass can use heuristics to determine whether a transformation should
296 /// be applied.
298
299 /// The transformation should be applied without considering a cost model.
301
302 /// The transformation should not be applied.
304
305 /// Force is a flag and should not be used alone.
306 TM_Force = 0x04,
307
308 /// The transformation was directed by the user, e.g. by a #pragma in
309 /// the source code. If the transformation could not be applied, a
310 /// warning should be emitted.
312
313 /// The transformation must not be applied. For instance, `#pragma clang loop
314 /// unroll(disable)` explicitly forbids any unrolling to take place. Unlike
315 /// general loop metadata, it must not be dropped. Most passes should not
316 /// behave differently under TM_Disable and TM_SuppressedByUser.
318};
319
320/// Return a short prefix describing the loop's vectorizer origin based on
321/// the \c llvm.loop.vectorize.body and \c llvm.loop.vectorize.epilogue
322/// metadata. The result is one of \c "vectorized epilogue ", \c "vectorized ",
323/// \c "epilogue ", or \c "" (empty) and is intended to be prepended to
324/// loop-kind tokens in optimization remarks.
325LLVM_ABI StringRef getLoopVectorizeKindPrefix(const Loop *L);
326
327/// @{
328/// Get the mode for LLVM's supported loop transformations.
334/// @}
335
336/// Set input string into loop metadata by keeping other values intact.
337/// If the string is already in loop metadata update value if it is
338/// different.
339LLVM_ABI void addStringMetadataToLoop(Loop *TheLoop, const char *MDString,
340 unsigned V = 0);
341
342/// Add a single-operand (name-only) node \p MDString to the loop metadata of
343/// \p TheLoop, keeping other values intact. If a name-only node with the same
344/// string is already present, this is a no-op.
345LLVM_ABI void addStringMetadataToLoop(Loop *TheLoop, StringRef MDString);
346
347/// Return either:
348/// - \c std::nullopt, if the implementation is unable to handle the loop form
349/// of \p L (e.g., \p L must have a latch block that controls the loop exit).
350/// - The value of \c llvm.loop.estimated_trip_count from the loop metadata of
351/// \p L, if that metadata is present.
352/// - Else, a new estimate of the trip count from the latch branch weights of
353/// \p L.
354///
355/// An estimate of zero is meaningful: it indicates that \p L is estimated not
356/// to be entered, that is, that its header is not reached. For example, after
357/// peeling 10 or more iterations from a loop with an estimated trip count of
358/// 10, \c llvm.loop.estimated_trip_count becomes 0 on the remaining loop.
359/// Callers that need a positive trip count must check for zero.
360///
361/// An estimated trip count is saturated at \c UINT_MAX.
362///
363/// In addition, if \p EstimatedLoopInvocationWeight, then either:
364/// - Set \c *EstimatedLoopInvocationWeight to the weight of the latch's branch
365/// to the loop exit.
366/// - Do not set it, and return \c std::nullopt, if the current implementation
367/// cannot compute that weight (e.g., if \p L does not have a latch block that
368/// controls the loop exit) or the weight is zero (because zero cannot be
369/// used to compute new branch weights that reflect the estimated trip count).
370///
371/// TODO: Eventually, once all passes have migrated away from setting branch
372/// weights to indicate estimated trip counts, this function will drop the
373/// \p EstimatedLoopInvocationWeight parameter.
374LLVM_ABI std::optional<unsigned>
376 unsigned *EstimatedLoopInvocationWeight = nullptr);
377
378/// Set \c llvm.loop.estimated_trip_count with the value \p EstimatedTripCount
379/// in the loop metadata of \p L. Return false if the implementation is unable
380/// to handle the loop form of \p L (e.g., \p L must have a latch block that
381/// controls the loop exit). Otherwise, return true.
382///
383/// In addition, if \p EstimatedLoopInvocationWeight:
384/// - Set the branch weight metadata of \p L to reflect that \p L has an
385/// estimated \p EstimatedTripCount iterations and has
386/// \c *EstimatedLoopInvocationWeight exit weight through the loop's latch.
387/// - If \p EstimatedTripCount is zero, set the backedge weight to 0 and exit
388/// edge to 1. The \p EstimatedTripCount is relative to the original loop
389/// entry, but the branch weights are encoding the probabilities of the
390/// true/false edges. The latter cannot validly be 0-0, because *if* the
391/// control flow arrived here, one of the branches *must* be taken. Moreover,
392/// BranchProbabilityInfo treats 0-0 branch weights as if they were 1-1.
393/// Assuming accurate profile information, a 0 \p EstimatedTripCount should
394/// correspond to a very low, or 0, BFI for the loop body. This should mean
395/// that the BPI info leading to the loop also gives a very low, or 0,
396/// probability to arriving there. If that probability is not exactly 0, 0-0
397/// branch weights would raise the BFI of the loop (as it would really be
398/// treated as 1-1). With the 0-1 (i.e. 100% exit) encoding, the BFI stays as
399/// low as the rest of the CFG's BPI dictates.
400///
401/// TODO: Eventually, once all passes have migrated away from setting branch
402/// weights to indicate estimated trip counts, this function will drop the
403/// \p EstimatedLoopInvocationWeight parameter.
405 Loop *L, unsigned EstimatedTripCount,
406 std::optional<unsigned> EstimatedLoopInvocationWeight = std::nullopt);
407
408/// Based on branch weight metadata, return either:
409/// - An unknown probability if the implementation is unable to handle the loop
410/// form of \p L (e.g., \p L must have a latch block that controls the loop
411/// exit).
412/// - The probability \c P that, at the end of any iteration, the latch of \p L
413/// will start another iteration such that `1 - P` is the probability of
414/// exiting the loop.
415LLVM_ABI BranchProbability getLoopProbability(Loop *L);
416
417/// Set branch weight metadata for the latch of \p L to indicate that, at the
418/// end of any iteration, \p P and `1 - P` are the probabilities of starting
419/// another iteration and exiting the loop, respectively. Return false if the
420/// implementation is unable to handle the loop form of \p L (e.g., \p L must
421/// have a latch block that controls the loop exit). Otherwise, return true.
422LLVM_ABI bool setLoopProbability(Loop *L, BranchProbability P);
423
424/// Based on branch weight metadata, return either:
425/// - An unknown probability if the implementation cannot extract the
426/// probability (e.g., \p B must have exactly two target labels, so it must be
427/// a conditional branch).
428/// - The probability \c P that control flows from \p B to its first target
429/// label such that `1 - P` is the probability of control flowing to its
430/// second target label, or vice-versa if \p ForFirstTarget is false.
431LLVM_ABI BranchProbability getBranchProbability(CondBrInst *B,
432 bool ForFirstTarget);
433
434/// Calculates the edge probability from Src to Dst.
435/// Dst has to be a successor to Src.
436/// This uses branch_weights metadata directly. If data are missing or
437/// probability cannot be computed, then unknown probability is returned.
438/// This does not use BranchProbabilityInfo and the values computed by this
439/// will vary from BPI because BPI has its own more advanced heuristics to
440/// determine probabilities even without branch_weights metadata.
441LLVM_ABI BranchProbability getBranchProbability(BasicBlock *Src,
442 BasicBlock *Dst);
443
444/// Set branch weight metadata for \p B to indicate that \p P and `1 - P` are
445/// the probabilities of control flowing to its first and second target labels,
446/// respectively, or vice-versa if \p ForFirstTarget is false.
447LLVM_ABI void setBranchProbability(CondBrInst *B, BranchProbability P,
448 bool ForFirstTarget);
449
450/// Check inner loop (L) backedge count is known to be invariant on all
451/// iterations of its outer loop. If the loop has no parent, this is trivially
452/// true.
453LLVM_ABI bool hasIterationCountInvariantInParent(Loop *L, ScalarEvolution &SE);
454
455/// Helper to consistently add the set of standard passes to a loop pass's \c
456/// AnalysisUsage.
457///
458/// All loop passes should call this as part of implementing their \c
459/// getAnalysisUsage.
460LLVM_ABI void getLoopAnalysisUsage(AnalysisUsage &AU);
461
462/// Returns true if is legal to hoist or sink this instruction disregarding the
463/// possible introduction of faults. Reasoning about potential faulting
464/// instructions is the responsibility of the caller since it is challenging to
465/// do efficiently from within this routine.
466/// \p TargetExecutesOncePerLoop is true only when it is guaranteed that the
467/// target executes at most once per execution of the loop body. This is used
468/// to assess the legality of duplicating atomic loads. Generally, this is
469/// true when moving out of loop and not true when moving into loops.
470/// If SinkAndHoistDependencies::ORE is set use it to emit optimization
471/// remarks.
472LLVM_ABI bool canSinkOrHoistInst(Instruction &I,
473 const SinkAndHoistDependencies &Deps,
474 Loop *CurLoop, bool TargetExecutesOncePerLoop,
475 SinkAndHoistLICMFlags &LICMFlags);
476
477/// Returns true if it is legal to hoist \p LI out of \p CurLoop. This is the
478/// load-specific subset of \c canSinkOrHoistInst: it rejects volatile or
479/// ordered loads, allows constant-memory / invariant.load / invariant.start-
480/// dominated loads unconditionally, and otherwise queries MemorySSA for an
481/// in-loop clobber. \p TargetExecutesOncePerLoop has the same meaning as in
482/// \c canSinkOrHoistInst (set to true when hoisting to the preheader).
483LLVM_ABI bool canHoistLoad(LoadInst &LI, const SinkAndHoistDependencies &Deps,
484 Loop *CurLoop, bool TargetExecutesOncePerLoop,
485 SinkAndHoistLICMFlags &LICMFlags);
486
487/// Returns the llvm.vector.reduce intrinsic that corresponds to the recurrence
488/// kind.
489LLVM_ABI constexpr Intrinsic::ID getReductionIntrinsicID(RecurKind RK);
490/// Returns the llvm.vector.reduce min/max intrinsic that corresponds to the
491/// intrinsic op.
493
494/// Returns the arithmetic instruction opcode used when expanding a reduction.
496/// Returns the reduction intrinsic id corresponding to the binary operation.
498
499/// Returns the min/max intrinsic used when expanding a min/max reduction.
501
502/// Returns the min/max intrinsic used when expanding a min/max reduction.
504
505/// Returns the recurence kind used when expanding a min/max reduction.
507
508/// Returns the comparison predicate used when expanding a min/max reduction.
510
511/// Given information about an @llvm.vector.reduce.* intrinsic, return
512/// the identity value for the reduction.
513LLVM_ABI Value *getReductionIdentity(Intrinsic::ID RdxID, Type *Ty,
514 FastMathFlags FMF);
515
516/// Given information about an recurrence kind, return the identity
517/// for the @llvm.vector.reduce.* used to generate it.
518LLVM_ABI Value *getRecurrenceIdentity(RecurKind K, Type *Tp, FastMathFlags FMF);
519
520/// Returns a Min/Max operation corresponding to MinMaxRecurrenceKind.
521/// The Builder's fast-math-flags must be set to propagate the expected values.
522LLVM_ABI Value *createMinMaxOp(IRBuilderBase &Builder, RecurKind RK,
523 Value *Left, Value *Right);
524
525/// Generates an ordered vector reduction using extracts to reduce the value.
526LLVM_ABI Value *getOrderedReduction(IRBuilderBase &Builder, Value *Acc,
527 Value *Src, unsigned Op,
528 RecurKind MinMaxKind = RecurKind::None);
529
530/// Expand a scalable vector reduction into a runtime loop that applies
531/// \p RdxOpcode element by element, starting from \p Acc as the initial
532/// accumulator value (typically the reduction identity).
533/// If \p DT and/or \p LI are provided, they are updated to reflect the
534/// new basic blocks.
535LLVM_ABI Value *expandReductionViaLoop(IRBuilderBase &Builder, Value *Vec,
536 unsigned RdxOpcode, Value *Acc,
537 DominatorTree *DT = nullptr,
538 LoopInfo *LI = nullptr);
539
540/// Generates a vector reduction using shufflevectors to reduce the value.
541/// Fast-math-flags are propagated using the IRBuilder's setting.
542LLVM_ABI Value *getShuffleReduction(IRBuilderBase &Builder, Value *Src,
543 unsigned Op,
545 RecurKind MinMaxKind = RecurKind::None);
546
547/// Create a reduction of the given vector. The reduction operation
548/// is described by the \p Opcode parameter. min/max reductions require
549/// additional information supplied in \p RdxKind.
550/// Fast-math-flags are propagated using the IRBuilder's setting.
551LLVM_ABI Value *createSimpleReduction(IRBuilderBase &B, Value *Src,
552 RecurKind RdxKind);
553/// Overloaded function to generate vector-predication intrinsics for
554/// reduction.
555LLVM_ABI Value *createSimpleReduction(IRBuilderBase &B, Value *Src,
556 RecurKind RdxKind, Value *Mask,
557 Value *EVL);
558
559/// Create an ordered reduction intrinsic using the given recurrence
560/// kind \p RdxKind.
561LLVM_ABI Value *createOrderedReduction(IRBuilderBase &B, RecurKind RdxKind,
562 Value *Src, Value *Start);
563/// Overloaded function to generate vector-predication intrinsics for ordered
564/// reduction.
565LLVM_ABI Value *createOrderedReduction(IRBuilderBase &B, RecurKind RdxKind,
566 Value *Src, Value *Start, Value *Mask,
567 Value *EVL);
568
569/// Get the intersection (logical and) of all of the potential IR flags
570/// of each scalar operation (VL) that will be converted into a vector (I).
571/// If OpValue is non-null, we only consider operations similar to OpValue
572/// when intersecting.
573/// Flag set: NSW, NUW (if IncludeWrapFlags is true), exact, and all of
574/// fast-math.
576 Value *OpValue = nullptr,
577 bool IncludeWrapFlags = true);
578
579/// Returns true if we can prove that \p S is defined and always negative in
580/// loop \p L.
581LLVM_ABI bool isKnownNegativeInLoop(const SCEV *S, const Loop *L,
582 ScalarEvolution &SE);
583
584/// Returns true if we can prove that \p S is defined and always non-negative in
585/// loop \p L.
586LLVM_ABI bool isKnownNonNegativeInLoop(const SCEV *S, const Loop *L,
587 ScalarEvolution &SE);
588/// Returns true if we can prove that \p S is defined and always positive in
589/// loop \p L.
590LLVM_ABI bool isKnownPositiveInLoop(const SCEV *S, const Loop *L,
591 ScalarEvolution &SE);
592
593/// Returns true if we can prove that \p S is defined and always non-positive in
594/// loop \p L.
595LLVM_ABI bool isKnownNonPositiveInLoop(const SCEV *S, const Loop *L,
596 ScalarEvolution &SE);
597
598/// Returns true if \p S is defined and never is equal to signed/unsigned max.
599LLVM_ABI bool cannotBeMaxInLoop(const SCEV *S, const Loop *L,
600 ScalarEvolution &SE, bool Signed);
601
602/// Returns true if \p S is defined and never is equal to signed/unsigned min.
603LLVM_ABI bool cannotBeMinInLoop(const SCEV *S, const Loop *L,
604 ScalarEvolution &SE, bool Signed);
605
613
614/// If the final value of any expressions that are recurrent in the loop can
615/// be computed, substitute the exit values from the loop into any instructions
616/// outside of the loop that use the final values of the current expressions.
617/// Return the number of loop exit values that have been replaced, and the
618/// corresponding phi node will be added to DeadInsts.
619LLVM_ABI int rewriteLoopExitValues(Loop *L, LoopInfo *LI,
620 TargetLibraryInfo *TLI, ScalarEvolution *SE,
621 const TargetTransformInfo *TTI,
622 SCEVExpander &Rewriter, DominatorTree *DT,
623 ReplaceExitVal ReplaceExitValue,
625
626/// Utility that implements appending of loops onto a worklist given a range.
627/// We want to process loops in postorder, but the worklist is a LIFO data
628/// structure, so we append to it in *reverse* postorder.
629/// For trees, a preorder traversal is a viable reverse postorder, so we
630/// actually append using a preorder walk algorithm.
631template <typename RangeT>
634/// Utility that implements appending of loops onto a worklist given a range.
635/// It has the same behavior as appendLoopsToWorklist, but assumes the range of
636/// loops has already been reversed, so it processes loops in the given order.
637template <typename RangeT>
638void appendReversedLoopsToWorklist(RangeT &&,
640
641extern template LLVM_TEMPLATE_ABI void
644
645extern template LLVM_TEMPLATE_ABI void
648
649/// Utility that implements appending of loops onto a worklist given LoopInfo.
650/// Calls the templated utility taking a Range of loops, handing it the Loops
651/// in LoopInfo, iterated in reverse. This is because the loops are stored in
652/// RPO w.r.t. the control flow graph in LoopInfo. For the purpose of unrolling,
653/// loop deletion, and LICM, we largely want to work forward across the CFG so
654/// that we visit defs before uses and can propagate simplifications from one
655/// loop nest into the next. Calls appendReversedLoopsToWorklist with the
656/// already reversed loops in LI.
657/// FIXME: Consider changing the order in LoopInfo.
660
661/// Recursively clone the specified loop and all of its children,
662/// mapping the blocks with the specified map.
664 LPPassManager *LPM);
665
666/// SCEV bounds of a pointer group: the first accessed byte, the last accessed
667/// byte plus one, and a stride that must be checked to be non-negative, if any.
669 const SCEV *Low;
670 const SCEV *High;
672};
673
674/// Return the bounds of \p CG in \p TheLoop. If \p HoistRuntimeChecks is true,
675/// bounds varying in the parent loop of \p TheLoop may be widened to cover the
676/// whole parent loop, so that checks using them can be hoisted out of it.
678getRuntimeCheckBounds(const RuntimeCheckingPtrGroup *CG, const Loop *TheLoop,
680
681/// Add code that checks at runtime if the accessed arrays in \p PointerChecks
682/// overlap. Returns the final comparator value or NULL if no check is needed.
685 const SmallVectorImpl<RuntimePointerCheck> &PointerChecks,
686 SCEVExpander &Expander, bool HoistRuntimeChecks = false);
687
690 SCEVExpander &Expander, ElementCount VF,
691 unsigned IC);
692
693/// Struct to hold information about a partially invariant condition.
695 /// Instructions that need to be duplicated and checked for the unswitching
696 /// condition.
698
699 /// Constant to indicate for which value the condition is invariant.
701
702 /// True if the partially invariant path is no-op (=does not have any
703 /// side-effects and no loop value is used outside the loop).
704 bool PathIsNoop = true;
705
706 /// If the partially invariant path reaches a single exit block, ExitForPath
707 /// is set to that block. Otherwise it is nullptr.
709};
710
711/// Check if the loop header has a conditional branch that is not
712/// loop-invariant, because it involves load instructions. If all paths from
713/// either the true or false successor to the header or loop exists do not
714/// modify the memory feeding the condition, perform 'partial unswitching'. That
715/// is, duplicate the instructions feeding the condition in the pre-header. Then
716/// unswitch on the duplicated condition. The condition is now known in the
717/// unswitched version for the 'invariant' path through the original loop.
718///
719/// If the branch condition of the header is partially invariant, return a pair
720/// containing the instructions to duplicate and a boolean Constant to update
721/// the condition in the loops created for the true or false successors.
722LLVM_ABI std::optional<IVConditionInfo>
723hasPartialIVCondition(const Loop &L, unsigned MSSAThreshold,
724 const MemorySSA &MSSA, AAResults &AA);
725
726/// Collect pointer values used by loads and stores whose addresses are derived
727/// from the conditional induction described by \p CondID. Add each pointer and
728/// an approximate SCEV expression for it to \p CompressedPtrs. The expression
729/// assumes that the conditional induction is incremented on every iteration.
730///
731/// Except for its backedge update, every value derived from \p CondID must be
732/// used only to compute an in-loop load/store address. The following
733/// restrictions also apply:
734/// - A value derived from \p CondID cannot be stored.
735/// - The allocation size of each access type must equal its type size. For
736/// example, types smaller than a byte, such as `i4`, are not supported.
737/// - The step of each pointer add recurrence must equal the access type's
738/// allocation size.
739/// Return true otherwise.
741 DenseMap<Value *, const SCEVAddRecExpr *> &CompressedPtrs, const Loop &L,
743
744} // end namespace llvm
745
746#endif // LLVM_TRANSFORMS_UTILS_LOOPUTILS_H
const TargetLowering & TLI
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_ABI
Definition Compiler.h:211
#define LLVM_TEMPLATE_ABI
Definition Compiler.h:212
Hexagon Hardware Loops
SmallVector< MachineOperand, 4 > Cond
unsigned Opc
static cl::opt< bool, true > HoistRuntimeChecks("hoist-runtime-checks", cl::Hidden, cl::desc("Hoist inner loop runtime memory checks to outer loop if possible"), cl::location(VectorizerParams::HoistRuntimeChecks), cl::init(true))
#define I(x, y, z)
Definition MD5.cpp:57
#define P(N)
This pass exposes codegen information to IR-level passes.
static const uint32_t IV[8]
Definition blake3_impl.h:83
Represent the analysis usage information of a pass.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
A cache of @llvm.assume calls within a function.
LLVM Basic Block Representation.
Definition BasicBlock.h:61
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Definition InstrTypes.h:740
Describes a conditional induction variable: an induction variable that is updated only on loop iterat...
This is an important base class in LLVM.
Definition Constant.h:44
Base class for the actual dominator tree node.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Definition Dominators.h:122
Context-sensitive CaptureAnalysis provider, which computes and caches the earliest common dominator c...
This implementation of LoopSafetyInfo use ImplicitControlFlowTracking to give precise answers on "may...
Common base class shared among various IRBuilders.
Definition IRBuilder.h:111
Represents a single loop in the control flow graph.
Definition LoopInfo.h:40
Metadata node.
Definition Metadata.h:1087
Encapsulates MemorySSA, including all data associated with memory accesses.
Definition MemorySSA.h:692
The optimization diagnostic interface.
PredIteratorCache - This class is an extremely trivial cache for predecessor iterator queries.
This node represents a polynomial recurrence on the trip count of the specified loop.
This class uses information about analyze scalars to rewrite expressions in canonical form.
This class represents an analyzed expression in the program.
The main scalar evolution driver.
Flags controlling how much is checked when sinking or hoisting instructions.
Definition LoopUtils.h:127
LLVM_ABI SinkAndHoistLICMFlags(unsigned LicmMssaOptCap, unsigned LicmMssaNoAccForPromotionCap, bool IsSink, Loop &L, MemorySSA &MSSA)
Definition LICM.cpp:354
unsigned LicmMssaNoAccForPromotionCap
Definition LoopUtils.h:146
A version of PriorityWorklist that selects small size optimized data structures for the vector and ma...
A SetVector that performs no allocations if smaller than a certain size.
Definition SetVector.h:346
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
Provides information about what library functions are available for the current target.
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
LLVM Value Representation.
Definition Value.h:75
Abstract Attribute helper functions.
Definition Attributor.h:166
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI Value * createSimpleReduction(IRBuilderBase &B, Value *Src, RecurKind RdxKind)
Create a reduction of the given vector.
LLVM_ABI std::optional< ElementCount > getOptionalElementCountLoopAttribute(const Loop *TheLoop)
Find a combination of metadata ("llvm.loop.vectorize.width" and "llvm.loop.vectorize....
LLVM_ABI bool collectCompressedPtrs(DenseMap< Value *, const SCEVAddRecExpr * > &CompressedPtrs, const Loop &L, const ConditionalInductionDescriptor &CondID, ScalarEvolution &SE)
Collect pointer values used by loads and stores whose addresses are derived from the conditional indu...
LLVM_ABI BranchProbability getBranchProbability(CondBrInst *B, bool ForFirstTarget)
Based on branch weight metadata, return either:
LLVM_ABI Value * addRuntimeChecks(Instruction *Loc, Loop *TheLoop, const SmallVectorImpl< RuntimePointerCheck > &PointerChecks, SCEVExpander &Expander, bool HoistRuntimeChecks=false)
Add code that checks at runtime if the accessed arrays in PointerChecks overlap.
LLVM_ABI std::optional< unsigned > getLoopEstimatedTripCount(Loop *L, unsigned *EstimatedLoopInvocationWeight=nullptr)
Return either:
LLVM_ABI BasicBlock * InsertPreheaderForLoop(Loop *L, DominatorTree *DT, LoopInfo *LI, MemorySSAUpdater *MSSAU, bool PreserveLCSSA)
InsertPreheaderForLoop - Once we discover that a loop doesn't have a preheader, this method is called...
LLVM_ABI Intrinsic::ID getMinMaxReductionIntrinsicOp(Intrinsic::ID RdxID)
Returns the min/max intrinsic used when expanding a min/max reduction.
LLVM_ABI bool isKnownNonPositiveInLoop(const SCEV *S, const Loop *L, ScalarEvolution &SE)
Returns true if we can prove that S is defined and always non-positive in loop L.
LLVM_ABI bool sinkRegionForLoopNest(DomTreeNode *, const LICMDependencies &, Loop *, SinkAndHoistLICMFlags &)
Call sinkRegion on loops contained within the specified loop in order from innermost to outermost.
Definition LICM.cpp:588
void appendReversedLoopsToWorklist(RangeT &&, SmallPriorityWorklist< Loop *, 4 > &)
Utility that implements appending of loops onto a worklist given a range.
LLVM_ABI bool formLCSSARecursively(Loop &L, const DominatorTree &DT, const LoopInfo *LI, ScalarEvolution *SE)
Put a loop nest into LCSSA form.
Definition LCSSA.cpp:469
LLVM_ABI Value * getReductionIdentity(Intrinsic::ID RdxID, Type *Ty, FastMathFlags FMF)
Given information about an @llvm.vector.reduce.
LLVM_ABI bool canHoistLoad(LoadInst &LI, const SinkAndHoistDependencies &Deps, Loop *CurLoop, bool TargetExecutesOncePerLoop, SinkAndHoistLICMFlags &LICMFlags)
Returns true if it is legal to hoist LI out of CurLoop.
Definition LICM.cpp:887
LLVM_ABI std::optional< MDNode * > makeFollowupLoopID(MDNode *OrigLoopID, ArrayRef< StringRef > FollowupAttrs, const char *InheritOptionsAttrsPrefix="", bool AlwaysNew=false)
Create a new loop identifier for a loop created from a loop transformation.
LLVM_ABI unsigned getArithmeticReductionInstruction(Intrinsic::ID RdxID)
Returns the arithmetic instruction opcode used when expanding a reduction.
std::pair< const RuntimeCheckingPtrGroup *, const RuntimeCheckingPtrGroup * > RuntimePointerCheck
A memcheck which made up of a pair of grouped pointers.
LLVM_ABI Value * createMinMaxOp(IRBuilderBase &Builder, RecurKind RK, Value *Left, Value *Right)
Returns a Min/Max operation corresponding to MinMaxRecurrenceKind.
LLVM_ABI SmallVector< BasicBlock *, 16 > collectChildrenInLoop(DominatorTree *DT, DomTreeNode *N, const Loop *CurLoop)
Does a BFS from a given node to all of its children inside a given loop.
LLVM_ABI void addStringMetadataToLoop(Loop *TheLoop, const char *MDString, unsigned V=0)
Set input string into loop metadata by keeping other values intact.
LLVM_ABI bool cannotBeMaxInLoop(const SCEV *S, const Loop *L, ScalarEvolution &SE, bool Signed)
Returns true if S is defined and never is equal to signed/unsigned max.
DomTreeNodeBase< BasicBlock > DomTreeNode
Definition Dominators.h:65
LLVM_ABI TransformationMode hasVectorizeTransformation(const Loop *L)
LLVM_ABI SmallVector< Instruction *, 8 > findDefsUsedOutsideOfLoop(Loop *L)
Returns the instructions that use values defined in the loop.
LLVM_ABI constexpr Intrinsic::ID getReductionIntrinsicID(RecurKind RK)
Returns the llvm.vector.reduce intrinsic that corresponds to the recurrence kind.
LLVM_ABI void setBranchProbability(CondBrInst *B, BranchProbability P, bool ForFirstTarget)
Set branch weight metadata for B to indicate that P and 1 - P are the probabilities of control flowin...
LLVM_ABI TransformationMode hasUnrollAndJamTransformation(const Loop *L)
LLVM_ABI void deleteDeadLoop(Loop *L, DominatorTree *DT, ScalarEvolution *SE, LoopInfo *LI, MemorySSA *MSSA=nullptr)
This function deletes dead loops.
LLVM_ABI bool hasDisableAllTransformsHint(const Loop *L)
Look for the loop attribute that disables all transformation heuristic.
LLVM_ABI bool canSinkOrHoistInst(Instruction &I, const SinkAndHoistDependencies &Deps, Loop *CurLoop, bool TargetExecutesOncePerLoop, SinkAndHoistLICMFlags &LICMFlags)
Returns true if is legal to hoist or sink this instruction disregarding the possible introduction of ...
Definition LICM.cpp:927
LLVM_TEMPLATE_ABI void appendLoopsToWorklist(RangeT &&, SmallPriorityWorklist< Loop *, 4 > &)
Utility that implements appending of loops onto a worklist given a range.
LLVM_ABI Value * getShuffleReduction(IRBuilderBase &Builder, Value *Src, unsigned Op, TargetTransformInfo::ReductionShuffle RS, RecurKind MinMaxKind=RecurKind::None)
Generates a vector reduction using shufflevectors to reduce the value.
LLVM_ABI TransformationMode hasUnrollTransformation(const Loop *L)
LLVM_ABI bool sinkRegion(DomTreeNode *, const LICMDependencies &, Loop *CurLoop, SinkAndHoistLICMFlags &, Loop *OutermostLoop=nullptr)
Walk the specified region of the CFG (defined by all blocks dominated by the specified block,...
Definition LICM.cpp:525
LLVM_ABI BranchProbability getLoopProbability(Loop *L)
Based on branch weight metadata, return either:
LLVM_ABI TransformationMode hasDistributeTransformation(const Loop *L)
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
LLVM_ABI void breakLoopBackedge(Loop *L, DominatorTree &DT, ScalarEvolution &SE, LoopInfo &LI, MemorySSA *MSSA)
Remove the backedge of the specified loop.
LLVM_ABI void getLoopAnalysisUsage(AnalysisUsage &AU)
Helper to consistently add the set of standard passes to a loop pass's AnalysisUsage.
LLVM_ABI void propagateIRFlags(Value *I, ArrayRef< Value * > VL, Value *OpValue=nullptr, bool IncludeWrapFlags=true)
Get the intersection (logical and) of all of the potential IR flags of each scalar operation (VL) tha...
LLVM_ABI bool isKnownPositiveInLoop(const SCEV *S, const Loop *L, ScalarEvolution &SE)
Returns true if we can prove that S is defined and always positive in loop L.
LLVM_ABI bool setLoopProbability(Loop *L, BranchProbability P)
Set branch weight metadata for the latch of L to indicate that, at the end of any iteration,...
TargetTransformInfo TTI
LLVM_ABI CmpInst::Predicate getMinMaxReductionPredicate(RecurKind RK)
Returns the comparison predicate used when expanding a min/max reduction.
LLVM_ABI TransformationMode hasLICMVersioningTransformation(const Loop *L)
TransformationMode
The mode sets how eager a transformation should be applied.
Definition LoopUtils.h:294
@ TM_Unspecified
The pass can use heuristics to determine whether a transformation should be applied.
Definition LoopUtils.h:297
@ TM_SuppressedByUser
The transformation must not be applied.
Definition LoopUtils.h:317
@ TM_ForcedByUser
The transformation was directed by the user, e.g.
Definition LoopUtils.h:311
@ TM_Disable
The transformation should not be applied.
Definition LoopUtils.h:303
@ TM_Force
Force is a flag and should not be used alone.
Definition LoopUtils.h:306
@ TM_Enable
The transformation should be applied without considering a cost model.
Definition LoopUtils.h:300
LLVM_ABI bool hasDisableLICMTransformsHint(const Loop *L)
Look for the loop attribute that disables the LICM transformation heuristics.
template LLVM_TEMPLATE_ABI void appendLoopsToWorklist< Loop & >(Loop &L, SmallPriorityWorklist< Loop *, 4 > &Worklist)
LLVM_ABI Intrinsic::ID getReductionForBinop(Instruction::BinaryOps Opc)
Returns the reduction intrinsic id corresponding to the binary operation.
@ None
Not a recurrence.
LLVM_ABI Value * getRecurrenceIdentity(RecurKind K, Type *Tp, FastMathFlags FMF)
Given information about an recurrence kind, return the identity for the @llvm.vector....
LLVM_ABI bool formDedicatedExitBlocks(Loop *L, DominatorTree *DT, LoopInfo *LI, MemorySSAUpdater *MSSAU, bool PreserveLCSSA)
Ensure that all exit blocks of the loop are dedicated exits.
Definition LoopUtils.cpp:59
DWARFExpression::Operation Op
ArrayRef(const T &OneElt) -> ArrayRef< T >
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.
LLVM_ABI StringRef getLoopVectorizeKindPrefix(const Loop *L)
Return a short prefix describing the loop's vectorizer origin based on the llvm.loop....
ValueMap< const Value *, WeakTrackingVH > ValueToValueMapTy
LLVM_ABI Value * expandReductionViaLoop(IRBuilderBase &Builder, Value *Vec, unsigned RdxOpcode, Value *Acc, DominatorTree *DT=nullptr, LoopInfo *LI=nullptr)
Expand a scalable vector reduction into a runtime loop that applies RdxOpcode element by element,...
LLVM_ABI bool setLoopEstimatedTripCount(Loop *L, unsigned EstimatedTripCount, std::optional< unsigned > EstimatedLoopInvocationWeight=std::nullopt)
Set llvm.loop.estimated_trip_count with the value EstimatedTripCount in the loop metadata of L.
LLVM_ABI bool formLCSSAForInstructions(SmallVectorImpl< Instruction * > &Worklist, const DominatorTree &DT, const LoopInfo &LI, ScalarEvolution *SE, SmallVectorImpl< PHINode * > *PHIsToRemove=nullptr, SmallVectorImpl< PHINode * > *InsertedPHIs=nullptr)
Ensures LCSSA form for every instruction from the Worklist in the scope of innermost containing loop.
Definition LCSSA.cpp:328
LLVM_ABI RuntimeCheckBounds getRuntimeCheckBounds(const RuntimeCheckingPtrGroup *CG, const Loop *TheLoop, ScalarEvolution &SE, bool HoistRuntimeChecks)
Return the bounds of CG in TheLoop.
LLVM_ABI bool hasIterationCountInvariantInParent(Loop *L, ScalarEvolution &SE)
Check inner loop (L) backedge count is known to be invariant on all iterations of its outer loop.
LLVM_ABI bool isAlmostDeadIV(PHINode *IV, BasicBlock *LatchBlock, Value *Cond)
Return true if the induction variable IV in a Loop whose latch is LatchBlock would become dead if the...
LLVM_ABI int rewriteLoopExitValues(Loop *L, LoopInfo *LI, TargetLibraryInfo *TLI, ScalarEvolution *SE, const TargetTransformInfo *TTI, SCEVExpander &Rewriter, DominatorTree *DT, ReplaceExitVal ReplaceExitValue, SmallVector< WeakTrackingVH, 16 > &DeadInsts)
If the final value of any expressions that are recurrent in the loop can be computed,...
LLVM_ABI Value * createOrderedReduction(IRBuilderBase &B, RecurKind RdxKind, Value *Src, Value *Start)
Create an ordered reduction intrinsic using the given recurrence kind RdxKind.
LLVM_ABI RecurKind getMinMaxReductionRecurKind(Intrinsic::ID RdxID)
Returns the recurence kind used when expanding a min/max reduction.
ReplaceExitVal
Definition LoopUtils.h:606
@ UnusedIndVarInLoop
Definition LoopUtils.h:610
@ OnlyCheapRepl
Definition LoopUtils.h:608
@ NeverRepl
Definition LoopUtils.h:607
@ NoHardUse
Definition LoopUtils.h:609
@ AlwaysRepl
Definition LoopUtils.h:611
LLVM_ABI std::optional< IVConditionInfo > hasPartialIVCondition(const Loop &L, unsigned MSSAThreshold, const MemorySSA &MSSA, AAResults &AA)
Check if the loop header has a conditional branch that is not loop-invariant, because it involves loa...
LLVM_ABI bool formLCSSA(Loop &L, const DominatorTree &DT, const LoopInfo *LI, ScalarEvolution *SE)
Put loop into LCSSA form.
Definition LCSSA.cpp:447
LLVM_ABI bool cannotBeMinInLoop(const SCEV *S, const Loop *L, ScalarEvolution &SE, bool Signed)
Returns true if S is defined and never is equal to signed/unsigned min.
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.
LLVM_ABI Value * addDiffRuntimeChecks(Instruction *Loc, ArrayRef< PointerDiffInfo > Checks, SCEVExpander &Expander, ElementCount VF, unsigned IC)
LLVM_ABI bool promoteLoopAccessesToScalars(const SmallSetVector< Value *, 8 > &, SmallVectorImpl< BasicBlock * > &, SmallVectorImpl< BasicBlock::iterator > &, SmallVectorImpl< MemoryAccess * > &, PredIteratorCache &, const LICMDependencies &, Loop *, bool AllowSpeculation, bool HasReadsOutsideSet)
Try to promote memory values to scalars by sinking stores out of the loop and moving loads to before ...
Definition LICM.cpp:1640
LLVM_ABI Value * getOrderedReduction(IRBuilderBase &Builder, Value *Acc, Value *Src, unsigned Op, RecurKind MinMaxKind=RecurKind::None)
Generates an ordered vector reduction using extracts to reduce the value.
LLVM_ABI bool hoistRegion(DomTreeNode *, const LICMDependencies &, Loop *, SinkAndHoistLICMFlags &, bool LoopNestMode, bool AllowSpeculation)
Walk the specified region of the CFG (defined by all blocks dominated by the specified block,...
Definition LICM.cpp:608
LLVM_ABI Intrinsic::ID getMinMaxReductionIntrinsicID(Intrinsic::ID IID)
Returns the llvm.vector.reduce min/max intrinsic that corresponds to the intrinsic op.
LLVM_ABI Loop * cloneLoop(Loop *L, Loop *PL, ValueToValueMapTy &VM, LoopInfo *LI, LPPassManager *LPM)
Recursively clone the specified loop and all of its children, mapping the blocks with the specified m...
#define N
Struct to hold information about a partially invariant condition.
Definition LoopUtils.h:694
BasicBlock * ExitForPath
If the partially invariant path reaches a single exit block, ExitForPath is set to that block.
Definition LoopUtils.h:708
SmallVector< Instruction * > InstToDuplicate
Instructions that need to be duplicated and checked for the unswitching condition.
Definition LoopUtils.h:697
Constant * KnownValue
Constant to indicate for which value the condition is invariant.
Definition LoopUtils.h:700
bool PathIsNoop
True if the partially invariant path is no-op (=does not have any side-effects and no loop value is u...
Definition LoopUtils.h:704
Dependencies required by LICM transforms.
Definition LoopUtils.h:160
ICFLoopSafetyInfo & SafetyInfo
Definition LoopUtils.h:166
TargetTransformInfo & TTI
Definition LoopUtils.h:164
ScalarEvolution * SE
Definition LoopUtils.h:165
TargetLibraryInfo & TLI
Definition LoopUtils.h:163
AssumptionCache & AC
Definition LoopUtils.h:161
SCEV bounds of a pointer group: the first accessed byte, the last accessed byte plus one,...
Definition LoopUtils.h:668
const SCEV * StrideToCheck
Definition LoopUtils.h:671
Dependencies required to check legality of sinking and hoisting.
Definition LoopUtils.h:151
OptimizationRemarkEmitter * ORE
Definition LoopUtils.h:156
EarliestEscapeAnalysis & EEA
Definition LoopUtils.h:155
MemorySSAUpdater & MSSAU
Definition LoopUtils.h:154