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;
44class LPPassManager;
45class Instruction;
47typedef std::pair<const RuntimeCheckingPtrGroup *,
50
51template <typename T, unsigned N> class SmallSetVector;
52template <typename T, unsigned N> class SmallPriorityWorklist;
53
55 LoopInfo *LI,
56 MemorySSAUpdater *MSSAU,
57 bool PreserveLCSSA);
58
59/// Ensure that all exit blocks of the loop are dedicated exits.
60///
61/// For any loop exit block with non-loop predecessors, we split the loop
62/// predecessors to use a dedicated loop exit block. We update the dominator
63/// tree and loop info if provided, and will preserve LCSSA if requested.
65 MemorySSAUpdater *MSSAU,
66 bool PreserveLCSSA);
67
68/// Ensures LCSSA form for every instruction from the Worklist in the scope of
69/// innermost containing loop.
70///
71/// For the given instruction which have uses outside of the loop, an LCSSA PHI
72/// node is inserted and the uses outside the loop are rewritten to use this
73/// node.
74///
75/// LoopInfo and DominatorTree are required and, since the routine makes no
76/// changes to CFG, preserved.
77///
78/// Returns true if any modifications are made.
79///
80/// This function may introduce unused PHI nodes. If \p PHIsToRemove is not
81/// nullptr, those are added to it (before removing, the caller has to check if
82/// they still do not have any uses). Otherwise the PHIs are directly removed.
83///
84/// If \p InsertedPHIs is not nullptr, inserted phis will be added to this
85/// vector.
86LLVM_ABI bool
88 const DominatorTree &DT, const LoopInfo &LI,
90 SmallVectorImpl<PHINode *> *PHIsToRemove = nullptr,
91 SmallVectorImpl<PHINode *> *InsertedPHIs = nullptr);
92
93/// Put loop into LCSSA form.
94///
95/// Looks at all instructions in the loop which have uses outside of the
96/// current loop. For each, an LCSSA PHI node is inserted and the uses outside
97/// the loop are rewritten to use this node. Sub-loops must be in LCSSA form
98/// already.
99///
100/// LoopInfo and DominatorTree are required and preserved.
101///
102/// If ScalarEvolution is passed in, it will be preserved.
103///
104/// Returns true if any modifications are made to the loop.
105LLVM_ABI bool formLCSSA(Loop &L, const DominatorTree &DT, const LoopInfo *LI,
106 ScalarEvolution *SE);
107
108/// Put a loop nest into LCSSA form.
109///
110/// This recursively forms LCSSA for a loop nest.
111///
112/// LoopInfo and DominatorTree are required and preserved.
113///
114/// If ScalarEvolution is passed in, it will be preserved.
115///
116/// Returns true if any modifications are made to the loop.
118 const LoopInfo *LI, ScalarEvolution *SE);
119
120/// Flags controlling how much is checked when sinking or hoisting
121/// instructions. The number of memory access in the loop (and whether there
122/// are too many) is determined in the constructors when using MemorySSA.
124public:
125 // Explicitly set limits.
128 bool IsSink, Loop &L, MemorySSA &MSSA);
129 // Use default limits.
131
132 void setIsSink(bool B) { IsSink = B; }
133 bool getIsSink() { return IsSink; }
137
138protected:
139 bool NoOfMemAccTooLarge = false;
140 unsigned LicmMssaOptCounter = 0;
143 bool IsSink;
144};
145
146/// Walk the specified region of the CFG (defined by all blocks
147/// dominated by the specified block, and that are in the current loop) in
148/// reverse depth first order w.r.t the DominatorTree. This allows us to visit
149/// uses before definitions, allowing us to sink a loop body in one pass without
150/// iteration. Takes DomTreeNode, AAResults, LoopInfo, DominatorTree,
151/// TargetLibraryInfo, Loop, AliasSet information for all
152/// instructions of the loop and loop safety information as
153/// arguments. Diagnostics is emitted via \p ORE. It returns changed status.
154/// \p CurLoop is a loop to do sinking on. \p OutermostLoop is used only when
155/// this function is called by \p sinkRegionForLoopNest.
158 TargetTransformInfo *, Loop *CurLoop,
161 Loop *OutermostLoop = nullptr);
162
163/// Call sinkRegion on loops contained within the specified loop
164/// in order from innermost to outermost.
171
172/// Walk the specified region of the CFG (defined by all blocks
173/// dominated by the specified block, and that are in the current loop) in depth
174/// first order w.r.t the DominatorTree. This allows us to visit definitions
175/// before uses, allowing us to hoist a loop body in one pass without iteration.
176/// Takes DomTreeNode, AAResults, LoopInfo, DominatorTree,
177/// TargetLibraryInfo, Loop, AliasSet information for all
178/// instructions of the loop and loop safety information as arguments.
179/// Diagnostics is emitted via \p ORE. It returns changed status.
180/// \p AllowSpeculation is whether values should be hoisted even if they are not
181/// guaranteed to execute in the loop, but are safe to speculatively execute.
187 bool, bool AllowSpeculation);
188
189/// Return true if the induction variable \p IV in a Loop whose latch is
190/// \p LatchBlock would become dead if the exit test \p Cond were removed.
191/// Conservatively returns false if analysis is insufficient.
193
194/// This function deletes dead loops. The caller of this function needs to
195/// guarantee that the loop is infact dead.
196/// The function requires a bunch or prerequisites to be present:
197/// - The loop needs to be in LCSSA form
198/// - The loop needs to have a Preheader
199/// - A unique dedicated exit block must exist
200///
201/// This also updates the relevant analysis information in \p DT, \p SE, \p LI
202/// and \p MSSA if pointers to those are provided.
203/// It also updates the loop PM if an updater struct is provided.
204
206 LoopInfo *LI, MemorySSA *MSSA = nullptr);
207
208/// Remove the backedge of the specified loop. Handles loop nests and general
209/// loop structures subject to the precondition that the loop has no parent
210/// loop and has a single latch block. Preserves all listed analyses.
212 LoopInfo &LI, MemorySSA *MSSA);
213
214/// Try to promote memory values to scalars by sinking stores out of
215/// the loop and moving loads to before the loop. We do this by looping over
216/// the stores in the loop, looking for stores to Must pointers which are
217/// loop invariant. It takes a set of must-alias values, Loop exit blocks
218/// vector, loop exit blocks insertion point vector, PredIteratorCache,
219/// LoopInfo, DominatorTree, Loop, AliasSet information for all instructions
220/// of the loop and loop safety information as arguments.
221/// Diagnostics is emitted via \p ORE. It returns changed status.
222/// \p AllowSpeculation is whether values should be hoisted even if they are not
223/// guaranteed to execute in the loop, but are safe to speculatively execute.
230 bool AllowSpeculation, bool HasReadsOutsideSet);
231
232/// Does a BFS from a given node to all of its children inside a given loop.
233/// The returned vector of basic blocks includes the starting point.
236
237/// Returns the instructions that use values defined in the loop.
239
240/// Find a combination of metadata ("llvm.loop.vectorize.width" and
241/// "llvm.loop.vectorize.scalable.enable") for a loop and use it to construct a
242/// ElementCount. If scalable.enable is present the count is scalable; if
243/// scalable.disable is present or the tag is absent, it is fixed-width. If the
244/// metadata "llvm.loop.vectorize.width" cannot be found then std::nullopt is
245/// returned.
246LLVM_ABI std::optional<ElementCount>
248
249/// Create a new loop identifier for a loop created from a loop transformation.
250///
251/// @param OrigLoopID The loop ID of the loop before the transformation.
252/// @param FollowupAttrs List of attribute names that contain attributes to be
253/// added to the new loop ID.
254/// @param InheritOptionsAttrsPrefix Selects which attributes should be inherited
255/// from the original loop. The following values
256/// are considered:
257/// nullptr : Inherit all attributes from @p OrigLoopID.
258/// "" : Do not inherit any attribute from @p OrigLoopID; only use
259/// those specified by a followup attribute.
260/// "<prefix>": Inherit all attributes except those which start with
261/// <prefix>; commonly used to remove metadata for the
262/// applied transformation.
263/// @param AlwaysNew If true, do not try to reuse OrigLoopID and never return
264/// std::nullopt.
265///
266/// @return The loop ID for the after-transformation loop. The following values
267/// can be returned:
268/// std::nullopt : No followup attribute was found; it is up to the
269/// transformation to choose attributes that make sense.
270/// @p OrigLoopID: The original identifier can be reused.
271/// nullptr : The new loop has no attributes.
272/// MDNode* : A new unique loop identifier.
273LLVM_ABI std::optional<MDNode *>
274makeFollowupLoopID(MDNode *OrigLoopID, ArrayRef<StringRef> FollowupAttrs,
275 const char *InheritOptionsAttrsPrefix = "",
276 bool AlwaysNew = false);
277
278/// Look for the loop attribute that disables all transformation heuristic.
280
281/// Look for the loop attribute that disables the LICM transformation heuristics.
283
284/// The mode sets how eager a transformation should be applied.
286 /// The pass can use heuristics to determine whether a transformation should
287 /// be applied.
289
290 /// The transformation should be applied without considering a cost model.
292
293 /// The transformation should not be applied.
295
296 /// Force is a flag and should not be used alone.
297 TM_Force = 0x04,
298
299 /// The transformation was directed by the user, e.g. by a #pragma in
300 /// the source code. If the transformation could not be applied, a
301 /// warning should be emitted.
303
304 /// The transformation must not be applied. For instance, `#pragma clang loop
305 /// unroll(disable)` explicitly forbids any unrolling to take place. Unlike
306 /// general loop metadata, it must not be dropped. Most passes should not
307 /// behave differently under TM_Disable and TM_SuppressedByUser.
309};
310
311/// Return a short prefix describing the loop's vectorizer origin based on
312/// the \c llvm.loop.vectorize.body and \c llvm.loop.vectorize.epilogue
313/// metadata. The result is one of \c "vectorized epilogue ", \c "vectorized ",
314/// \c "epilogue ", or \c "" (empty) and is intended to be prepended to
315/// loop-kind tokens in optimization remarks.
316LLVM_ABI StringRef getLoopVectorizeKindPrefix(const Loop *L);
317
318/// @{
319/// Get the mode for LLVM's supported loop transformations.
325/// @}
326
327/// Set input string into loop metadata by keeping other values intact.
328/// If the string is already in loop metadata update value if it is
329/// different.
330LLVM_ABI void addStringMetadataToLoop(Loop *TheLoop, const char *MDString,
331 unsigned V = 0);
332
333/// Add a single-operand (name-only) node \p MDString to the loop metadata of
334/// \p TheLoop, keeping other values intact. If a name-only node with the same
335/// string is already present, this is a no-op.
336LLVM_ABI void addStringMetadataToLoop(Loop *TheLoop, StringRef MDString);
337
338/// Return either:
339/// - \c std::nullopt, if the implementation is unable to handle the loop form
340/// of \p L (e.g., \p L must have a latch block that controls the loop exit).
341/// - The value of \c llvm.loop.estimated_trip_count from the loop metadata of
342/// \p L, if that metadata is present.
343/// - Else, a new estimate of the trip count from the latch branch weights of
344/// \p L.
345///
346/// An estimate of zero is meaningful: it indicates that \p L is estimated not
347/// to be entered, that is, that its header is not reached. For example, after
348/// peeling 10 or more iterations from a loop with an estimated trip count of
349/// 10, \c llvm.loop.estimated_trip_count becomes 0 on the remaining loop.
350/// Callers that need a positive trip count must check for zero.
351///
352/// An estimated trip count is saturated at \c UINT_MAX.
353///
354/// In addition, if \p EstimatedLoopInvocationWeight, then either:
355/// - Set \c *EstimatedLoopInvocationWeight to the weight of the latch's branch
356/// to the loop exit.
357/// - Do not set it, and return \c std::nullopt, if the current implementation
358/// cannot compute that weight (e.g., if \p L does not have a latch block that
359/// controls the loop exit) or the weight is zero (because zero cannot be
360/// used to compute new branch weights that reflect the estimated trip count).
361///
362/// TODO: Eventually, once all passes have migrated away from setting branch
363/// weights to indicate estimated trip counts, this function will drop the
364/// \p EstimatedLoopInvocationWeight parameter.
365LLVM_ABI std::optional<unsigned>
367 unsigned *EstimatedLoopInvocationWeight = nullptr);
368
369/// Set \c llvm.loop.estimated_trip_count with the value \p EstimatedTripCount
370/// in the loop metadata of \p L. Return false if the implementation is unable
371/// to handle the loop form of \p L (e.g., \p L must have a latch block that
372/// controls the loop exit). Otherwise, return true.
373///
374/// In addition, if \p EstimatedLoopInvocationWeight:
375/// - Set the branch weight metadata of \p L to reflect that \p L has an
376/// estimated \p EstimatedTripCount iterations and has
377/// \c *EstimatedLoopInvocationWeight exit weight through the loop's latch.
378/// - If \p EstimatedTripCount is zero, set the backedge weight to 0 and exit
379/// edge to 1. The \p EstimatedTripCount is relative to the original loop
380/// entry, but the branch weights are encoding the probabilities of the
381/// true/false edges. The latter cannot validly be 0-0, because *if* the
382/// control flow arrived here, one of the branches *must* be taken. Moreover,
383/// BranchProbabilityInfo treats 0-0 branch weights as if they were 1-1.
384/// Assuming accurate profile information, a 0 \p EstimatedTripCount should
385/// correspond to a very low, or 0, BFI for the loop body. This should mean
386/// that the BPI info leading to the loop also gives a very low, or 0,
387/// probability to arriving there. If that probability is not exactly 0, 0-0
388/// branch weights would raise the BFI of the loop (as it would really be
389/// treated as 1-1). With the 0-1 (i.e. 100% exit) encoding, the BFI stays as
390/// low as the rest of the CFG's BPI dictates.
391///
392/// TODO: Eventually, once all passes have migrated away from setting branch
393/// weights to indicate estimated trip counts, this function will drop the
394/// \p EstimatedLoopInvocationWeight parameter.
396 Loop *L, unsigned EstimatedTripCount,
397 std::optional<unsigned> EstimatedLoopInvocationWeight = std::nullopt);
398
399/// Based on branch weight metadata, return either:
400/// - An unknown probability if the implementation is unable to handle the loop
401/// form of \p L (e.g., \p L must have a latch block that controls the loop
402/// exit).
403/// - The probability \c P that, at the end of any iteration, the latch of \p L
404/// will start another iteration such that `1 - P` is the probability of
405/// exiting the loop.
406LLVM_ABI BranchProbability getLoopProbability(Loop *L);
407
408/// Set branch weight metadata for the latch of \p L to indicate that, at the
409/// end of any iteration, \p P and `1 - P` are the probabilities of starting
410/// another iteration and exiting the loop, respectively. Return false if the
411/// implementation is unable to handle the loop form of \p L (e.g., \p L must
412/// have a latch block that controls the loop exit). Otherwise, return true.
413LLVM_ABI bool setLoopProbability(Loop *L, BranchProbability P);
414
415/// Based on branch weight metadata, return either:
416/// - An unknown probability if the implementation cannot extract the
417/// probability (e.g., \p B must have exactly two target labels, so it must be
418/// a conditional branch).
419/// - The probability \c P that control flows from \p B to its first target
420/// label such that `1 - P` is the probability of control flowing to its
421/// second target label, or vice-versa if \p ForFirstTarget is false.
422LLVM_ABI BranchProbability getBranchProbability(CondBrInst *B,
423 bool ForFirstTarget);
424
425/// Calculates the edge probability from Src to Dst.
426/// Dst has to be a successor to Src.
427/// This uses branch_weights metadata directly. If data are missing or
428/// probability cannot be computed, then unknown probability is returned.
429/// This does not use BranchProbabilityInfo and the values computed by this
430/// will vary from BPI because BPI has its own more advanced heuristics to
431/// determine probabilities even without branch_weights metadata.
432LLVM_ABI BranchProbability getBranchProbability(BasicBlock *Src,
433 BasicBlock *Dst);
434
435/// Set branch weight metadata for \p B to indicate that \p P and `1 - P` are
436/// the probabilities of control flowing to its first and second target labels,
437/// respectively, or vice-versa if \p ForFirstTarget is false.
438LLVM_ABI void setBranchProbability(CondBrInst *B, BranchProbability P,
439 bool ForFirstTarget);
440
441/// Check inner loop (L) backedge count is known to be invariant on all
442/// iterations of its outer loop. If the loop has no parent, this is trivially
443/// true.
444LLVM_ABI bool hasIterationCountInvariantInParent(Loop *L, ScalarEvolution &SE);
445
446/// Helper to consistently add the set of standard passes to a loop pass's \c
447/// AnalysisUsage.
448///
449/// All loop passes should call this as part of implementing their \c
450/// getAnalysisUsage.
451LLVM_ABI void getLoopAnalysisUsage(AnalysisUsage &AU);
452
453/// Returns true if is legal to hoist or sink this instruction disregarding the
454/// possible introduction of faults. Reasoning about potential faulting
455/// instructions is the responsibility of the caller since it is challenging to
456/// do efficiently from within this routine.
457/// \p TargetExecutesOncePerLoop is true only when it is guaranteed that the
458/// target executes at most once per execution of the loop body. This is used
459/// to assess the legality of duplicating atomic loads. Generally, this is
460/// true when moving out of loop and not true when moving into loops.
461/// If \p ORE is set use it to emit optimization remarks.
462LLVM_ABI bool canSinkOrHoistInst(Instruction &I, AAResults *AA,
463 DominatorTree *DT, Loop *CurLoop,
464 MemorySSAUpdater &MSSAU,
465 bool TargetExecutesOncePerLoop,
466 SinkAndHoistLICMFlags &LICMFlags,
467 OptimizationRemarkEmitter *ORE = nullptr);
468
469/// Returns true if it is legal to hoist \p LI out of \p CurLoop. This is the
470/// load-specific subset of \c canSinkOrHoistInst: it rejects volatile or
471/// ordered loads, allows constant-memory / invariant.load / invariant.start-
472/// dominated loads unconditionally, and otherwise queries \p MSSA for an
473/// in-loop clobber. \p TargetExecutesOncePerLoop has the same meaning as in
474/// \c canSinkOrHoistInst (set to true when hoisting to the preheader).
475LLVM_ABI bool canHoistLoad(LoadInst &LI, AAResults *AA, DominatorTree *DT,
476 Loop *CurLoop, MemorySSA &MSSA,
477 bool TargetExecutesOncePerLoop,
478 SinkAndHoistLICMFlags &LICMFlags,
479 OptimizationRemarkEmitter *ORE = nullptr);
480
481/// Returns the llvm.vector.reduce intrinsic that corresponds to the recurrence
482/// kind.
483LLVM_ABI constexpr Intrinsic::ID getReductionIntrinsicID(RecurKind RK);
484/// Returns the llvm.vector.reduce min/max intrinsic that corresponds to the
485/// intrinsic op.
487
488/// Returns the arithmetic instruction opcode used when expanding a reduction.
490/// Returns the reduction intrinsic id corresponding to the binary operation.
492
493/// Returns the min/max intrinsic used when expanding a min/max reduction.
495
496/// Returns the min/max intrinsic used when expanding a min/max reduction.
498
499/// Returns the recurence kind used when expanding a min/max reduction.
501
502/// Returns the comparison predicate used when expanding a min/max reduction.
504
505/// Given information about an @llvm.vector.reduce.* intrinsic, return
506/// the identity value for the reduction.
507LLVM_ABI Value *getReductionIdentity(Intrinsic::ID RdxID, Type *Ty,
508 FastMathFlags FMF);
509
510/// Given information about an recurrence kind, return the identity
511/// for the @llvm.vector.reduce.* used to generate it.
512LLVM_ABI Value *getRecurrenceIdentity(RecurKind K, Type *Tp, FastMathFlags FMF);
513
514/// Returns a Min/Max operation corresponding to MinMaxRecurrenceKind.
515/// The Builder's fast-math-flags must be set to propagate the expected values.
516LLVM_ABI Value *createMinMaxOp(IRBuilderBase &Builder, RecurKind RK,
517 Value *Left, Value *Right);
518
519/// Generates an ordered vector reduction using extracts to reduce the value.
520LLVM_ABI Value *getOrderedReduction(IRBuilderBase &Builder, Value *Acc,
521 Value *Src, unsigned Op,
522 RecurKind MinMaxKind = RecurKind::None);
523
524/// Expand a scalable vector reduction into a runtime loop that applies
525/// \p RdxOpcode element by element, starting from \p Acc as the initial
526/// accumulator value (typically the reduction identity).
527/// If \p DT and/or \p LI are provided, they are updated to reflect the
528/// new basic blocks.
529LLVM_ABI Value *expandReductionViaLoop(IRBuilderBase &Builder, Value *Vec,
530 unsigned RdxOpcode, Value *Acc,
531 DominatorTree *DT = nullptr,
532 LoopInfo *LI = nullptr);
533
534/// Generates a vector reduction using shufflevectors to reduce the value.
535/// Fast-math-flags are propagated using the IRBuilder's setting.
536LLVM_ABI Value *getShuffleReduction(IRBuilderBase &Builder, Value *Src,
537 unsigned Op,
539 RecurKind MinMaxKind = RecurKind::None);
540
541/// Create a reduction of the given vector. The reduction operation
542/// is described by the \p Opcode parameter. min/max reductions require
543/// additional information supplied in \p RdxKind.
544/// Fast-math-flags are propagated using the IRBuilder's setting.
545LLVM_ABI Value *createSimpleReduction(IRBuilderBase &B, Value *Src,
546 RecurKind RdxKind);
547/// Overloaded function to generate vector-predication intrinsics for
548/// reduction.
549LLVM_ABI Value *createSimpleReduction(IRBuilderBase &B, Value *Src,
550 RecurKind RdxKind, Value *Mask,
551 Value *EVL);
552
553/// Create a reduction of the given vector \p Src for a reduction of kind
554/// RecurKind::AnyOf. The start value of the reduction is \p InitVal.
555LLVM_ABI Value *createAnyOfReduction(IRBuilderBase &B, Value *Src,
556 Value *InitVal, PHINode *OrigPhi);
557
558/// Create an ordered reduction intrinsic using the given recurrence
559/// kind \p RdxKind.
560LLVM_ABI Value *createOrderedReduction(IRBuilderBase &B, RecurKind RdxKind,
561 Value *Src, Value *Start);
562/// Overloaded function to generate vector-predication intrinsics for ordered
563/// reduction.
564LLVM_ABI Value *createOrderedReduction(IRBuilderBase &B, RecurKind RdxKind,
565 Value *Src, Value *Start, Value *Mask,
566 Value *EVL);
567
568/// Get the intersection (logical and) of all of the potential IR flags
569/// of each scalar operation (VL) that will be converted into a vector (I).
570/// If OpValue is non-null, we only consider operations similar to OpValue
571/// when intersecting.
572/// Flag set: NSW, NUW (if IncludeWrapFlags is true), exact, and all of
573/// fast-math.
575 Value *OpValue = nullptr,
576 bool IncludeWrapFlags = true);
577
578/// Returns true if we can prove that \p S is defined and always negative in
579/// loop \p L.
580LLVM_ABI bool isKnownNegativeInLoop(const SCEV *S, const Loop *L,
581 ScalarEvolution &SE);
582
583/// Returns true if we can prove that \p S is defined and always non-negative in
584/// loop \p L.
585LLVM_ABI bool isKnownNonNegativeInLoop(const SCEV *S, const Loop *L,
586 ScalarEvolution &SE);
587/// Returns true if we can prove that \p S is defined and always positive in
588/// loop \p L.
589LLVM_ABI bool isKnownPositiveInLoop(const SCEV *S, const Loop *L,
590 ScalarEvolution &SE);
591
592/// Returns true if we can prove that \p S is defined and always non-positive in
593/// loop \p L.
594LLVM_ABI bool isKnownNonPositiveInLoop(const SCEV *S, const Loop *L,
595 ScalarEvolution &SE);
596
597/// Returns true if \p S is defined and never is equal to signed/unsigned max.
598LLVM_ABI bool cannotBeMaxInLoop(const SCEV *S, const Loop *L,
599 ScalarEvolution &SE, bool Signed);
600
601/// Returns true if \p S is defined and never is equal to signed/unsigned min.
602LLVM_ABI bool cannotBeMinInLoop(const SCEV *S, const Loop *L,
603 ScalarEvolution &SE, bool Signed);
604
612
613/// If the final value of any expressions that are recurrent in the loop can
614/// be computed, substitute the exit values from the loop into any instructions
615/// outside of the loop that use the final values of the current expressions.
616/// Return the number of loop exit values that have been replaced, and the
617/// corresponding phi node will be added to DeadInsts.
618LLVM_ABI int rewriteLoopExitValues(Loop *L, LoopInfo *LI,
619 TargetLibraryInfo *TLI, ScalarEvolution *SE,
620 const TargetTransformInfo *TTI,
621 SCEVExpander &Rewriter, DominatorTree *DT,
624
625/// Utility that implements appending of loops onto a worklist given a range.
626/// We want to process loops in postorder, but the worklist is a LIFO data
627/// structure, so we append to it in *reverse* postorder.
628/// For trees, a preorder traversal is a viable reverse postorder, so we
629/// actually append using a preorder walk algorithm.
630template <typename RangeT>
633/// Utility that implements appending of loops onto a worklist given a range.
634/// It has the same behavior as appendLoopsToWorklist, but assumes the range of
635/// loops has already been reversed, so it processes loops in the given order.
636template <typename RangeT>
637void appendReversedLoopsToWorklist(RangeT &&,
639
640extern template LLVM_TEMPLATE_ABI void
643
644extern template LLVM_TEMPLATE_ABI void
647
648/// Utility that implements appending of loops onto a worklist given LoopInfo.
649/// Calls the templated utility taking a Range of loops, handing it the Loops
650/// in LoopInfo, iterated in reverse. This is because the loops are stored in
651/// RPO w.r.t. the control flow graph in LoopInfo. For the purpose of unrolling,
652/// loop deletion, and LICM, we largely want to work forward across the CFG so
653/// that we visit defs before uses and can propagate simplifications from one
654/// loop nest into the next. Calls appendReversedLoopsToWorklist with the
655/// already reversed loops in LI.
656/// FIXME: Consider changing the order in LoopInfo.
659
660/// Recursively clone the specified loop and all of its children,
661/// mapping the blocks with the specified map.
663 LPPassManager *LPM);
664
665/// Add code that checks at runtime if the accessed arrays in \p PointerChecks
666/// overlap. Returns the final comparator value or NULL if no check is needed.
669 const SmallVectorImpl<RuntimePointerCheck> &PointerChecks,
670 SCEVExpander &Expander, bool HoistRuntimeChecks = false);
671
674 SCEVExpander &Expander, ElementCount VF,
675 unsigned IC);
676
677/// Struct to hold information about a partially invariant condition.
679 /// Instructions that need to be duplicated and checked for the unswitching
680 /// condition.
682
683 /// Constant to indicate for which value the condition is invariant.
685
686 /// True if the partially invariant path is no-op (=does not have any
687 /// side-effects and no loop value is used outside the loop).
688 bool PathIsNoop = true;
689
690 /// If the partially invariant path reaches a single exit block, ExitForPath
691 /// is set to that block. Otherwise it is nullptr.
693};
694
695/// Check if the loop header has a conditional branch that is not
696/// loop-invariant, because it involves load instructions. If all paths from
697/// either the true or false successor to the header or loop exists do not
698/// modify the memory feeding the condition, perform 'partial unswitching'. That
699/// is, duplicate the instructions feeding the condition in the pre-header. Then
700/// unswitch on the duplicated condition. The condition is now known in the
701/// unswitched version for the 'invariant' path through the original loop.
702///
703/// If the branch condition of the header is partially invariant, return a pair
704/// containing the instructions to duplicate and a boolean Constant to update
705/// the condition in the loops created for the true or false successors.
706LLVM_ABI std::optional<IVConditionInfo>
707hasPartialIVCondition(const Loop &L, unsigned MSSAThreshold,
708 const MemorySSA &MSSA, AAResults &AA);
709
710} // end namespace llvm
711
712#endif // LLVM_TRANSFORMS_UTILS_LOOPUTILS_H
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_ABI
Definition Compiler.h:215
#define LLVM_TEMPLATE_ABI
Definition Compiler.h:216
early cse Early CSE w MemorySSA
Hexagon Hardware Loops
static cl::opt< ReplaceExitVal > ReplaceExitValue("replexitval", cl::Hidden, cl::init(OnlyCheapRepl), cl::desc("Choose the strategy to replace exit value in IndVarSimplify"), cl::values(clEnumValN(NeverRepl, "never", "never replace exit value"), clEnumValN(OnlyCheapRepl, "cheap", "only replace exit value when the cost is cheap"), clEnumValN(UnusedIndVarInLoop, "unusedindvarinloop", "only replace exit value when it is an unused " "induction variable in the loop and has cheap replacement cost"), clEnumValN(NoHardUse, "noharduse", "only replace exit values when loop def likely dead"), clEnumValN(AlwaysRepl, "always", "always replace exit value whenever possible")))
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)
const SmallVectorImpl< MachineOperand > & Cond
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:62
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Definition InstrTypes.h:740
This is an important base class in LLVM.
Definition Constant.h:43
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
This implementation of LoopSafetyInfo use ImplicitControlFlowTracking to give precise answers on "may...
Common base class shared among various IRBuilders.
Definition IRBuilder.h:114
Represents a single loop in the control flow graph.
Definition LoopInfo.h:40
Metadata node.
Definition Metadata.h:1069
Encapsulates MemorySSA, including all data associated with memory accesses.
Definition MemorySSA.h:702
The optimization diagnostic interface.
PredIteratorCache - This class is an extremely trivial cache for predecessor iterator queries.
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:123
LLVM_ABI SinkAndHoistLICMFlags(unsigned LicmMssaOptCap, unsigned LicmMssaNoAccForPromotionCap, bool IsSink, Loop &L, MemorySSA &MSSA)
Definition LICM.cpp:401
unsigned LicmMssaNoAccForPromotionCap
Definition LoopUtils.h:142
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:345
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:165
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 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 canSinkOrHoistInst(Instruction &I, AAResults *AA, DominatorTree *DT, Loop *CurLoop, MemorySSAUpdater &MSSAU, bool TargetExecutesOncePerLoop, SinkAndHoistLICMFlags &LICMFlags, OptimizationRemarkEmitter *ORE=nullptr)
Returns true if is legal to hoist or sink this instruction disregarding the possible introduction of ...
Definition LICM.cpp:1294
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.
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 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 bool hoistRegion(DomTreeNode *, AAResults *, LoopInfo *, DominatorTree *, AssumptionCache *, TargetLibraryInfo *, Loop *, MemorySSAUpdater &, ScalarEvolution *, ICFLoopSafetyInfo *, SinkAndHoistLICMFlags &, OptimizationRemarkEmitter *, bool, bool AllowSpeculation)
Walk the specified region of the CFG (defined by all blocks dominated by the specified block,...
Definition LICM.cpp:896
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_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 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:285
@ TM_Unspecified
The pass can use heuristics to determine whether a transformation should be applied.
Definition LoopUtils.h:288
@ TM_SuppressedByUser
The transformation must not be applied.
Definition LoopUtils.h:308
@ TM_ForcedByUser
The transformation was directed by the user, e.g.
Definition LoopUtils.h:302
@ TM_Disable
The transformation should not be applied.
Definition LoopUtils.h:294
@ TM_Force
Force is a flag and should not be used alone.
Definition LoopUtils.h:297
@ TM_Enable
The transformation should be applied without considering a cost model.
Definition LoopUtils.h:291
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:61
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 bool hasIterationCountInvariantInParent(Loop *L, ScalarEvolution &SE)
Check inner loop (L) backedge count is known to be invariant on all iterations of its outer loop.
static cl::opt< unsigned > MSSAThreshold("simple-loop-unswitch-memoryssa-threshold", cl::desc("Max number of memory uses to explore during " "partial unswitching analysis"), cl::init(100), cl::Hidden)
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 bool sinkRegion(DomTreeNode *, AAResults *, LoopInfo *, DominatorTree *, TargetLibraryInfo *, TargetTransformInfo *, Loop *CurLoop, MemorySSAUpdater &, ICFLoopSafetyInfo *, SinkAndHoistLICMFlags &, OptimizationRemarkEmitter *, Loop *OutermostLoop=nullptr)
Walk the specified region of the CFG (defined by all blocks dominated by the specified block,...
Definition LICM.cpp:567
LLVM_ABI RecurKind getMinMaxReductionRecurKind(Intrinsic::ID RdxID)
Returns the recurence kind used when expanding a min/max reduction.
ReplaceExitVal
Definition LoopUtils.h:605
@ UnusedIndVarInLoop
Definition LoopUtils.h:609
@ OnlyCheapRepl
Definition LoopUtils.h:607
@ NeverRepl
Definition LoopUtils.h:606
@ NoHardUse
Definition LoopUtils.h:608
@ AlwaysRepl
Definition LoopUtils.h:610
LLVM_ABI bool canHoistLoad(LoadInst &LI, AAResults *AA, DominatorTree *DT, Loop *CurLoop, MemorySSA &MSSA, bool TargetExecutesOncePerLoop, SinkAndHoistLICMFlags &LICMFlags, OptimizationRemarkEmitter *ORE=nullptr)
Returns true if it is legal to hoist LI out of CurLoop.
Definition LICM.cpp:1253
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 promoteLoopAccessesToScalars(const SmallSetVector< Value *, 8 > &, SmallVectorImpl< BasicBlock * > &, SmallVectorImpl< BasicBlock::iterator > &, SmallVectorImpl< MemoryAccess * > &, PredIteratorCache &, LoopInfo *, DominatorTree *, AssumptionCache *AC, const TargetLibraryInfo *, TargetTransformInfo *, Loop *, MemorySSAUpdater &, ICFLoopSafetyInfo *, OptimizationRemarkEmitter *, 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:2008
LLVM_ABI Value * createAnyOfReduction(IRBuilderBase &B, Value *Src, Value *InitVal, PHINode *OrigPhi)
Create a reduction of the given vector Src for a reduction of kind RecurKind::AnyOf.
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 bool sinkRegionForLoopNest(DomTreeNode *, AAResults *, LoopInfo *, DominatorTree *, TargetLibraryInfo *, TargetTransformInfo *, Loop *, MemorySSAUpdater &, ICFLoopSafetyInfo *, SinkAndHoistLICMFlags &, OptimizationRemarkEmitter *)
Call sinkRegion on loops contained within the specified loop in order from innermost to outermost.
Definition LICM.cpp:634
LLVM_ABI Value * addDiffRuntimeChecks(Instruction *Loc, ArrayRef< PointerDiffInfo > Checks, SCEVExpander &Expander, ElementCount VF, unsigned IC)
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 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:678
BasicBlock * ExitForPath
If the partially invariant path reaches a single exit block, ExitForPath is set to that block.
Definition LoopUtils.h:692
SmallVector< Instruction * > InstToDuplicate
Instructions that need to be duplicated and checked for the unswitching condition.
Definition LoopUtils.h:681
Constant * KnownValue
Constant to indicate for which value the condition is invariant.
Definition LoopUtils.h:684
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:688