LLVM 22.0.0git
VPlanTransforms.h
Go to the documentation of this file.
1//===- VPlanTransforms.h - Utility VPlan to VPlan transforms --------------===//
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/// \file
10/// This file provides utility VPlan to VPlan transformations.
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_TRANSFORMS_VECTORIZE_VPLANTRANSFORMS_H
14#define LLVM_TRANSFORMS_VECTORIZE_VPLANTRANSFORMS_H
15
16#include "VPlan.h"
17#include "VPlanVerifier.h"
21
22namespace llvm {
23
25class Instruction;
26class PHINode;
27class ScalarEvolution;
30class VPBuilder;
31class VPRecipeBuilder;
32struct VFRange;
33
36
38 /// Helper to run a VPlan transform \p Transform on \p VPlan, forwarding extra
39 /// arguments to the transform. Returns the boolean returned by the transform.
40 template <typename... ArgsTy>
41 static bool runPass(bool (*Transform)(VPlan &, ArgsTy...), VPlan &Plan,
42 typename std::remove_reference<ArgsTy>::type &...Args) {
43 bool Res = Transform(Plan, Args...);
46 return Res;
47 }
48 /// Helper to run a VPlan transform \p Transform on \p VPlan, forwarding extra
49 /// arguments to the transform.
50 template <typename... ArgsTy>
51 static void runPass(void (*Fn)(VPlan &, ArgsTy...), VPlan &Plan,
52 typename std::remove_reference<ArgsTy>::type &...Args) {
53 Fn(Plan, Args...);
56 }
57
58 /// Create a base VPlan0, serving as the common starting point for all later
59 /// candidates. It consists of an initial plain CFG loop with loop blocks from
60 /// \p TheLoop being directly translated to VPBasicBlocks with VPInstruction
61 /// corresponding to the input IR.
62 ///
63 /// The created loop is wrapped in an initial skeleton to facilitate
64 /// vectorization, consisting of a vector pre-header, an exit block for the
65 /// main vector loop (middle.block) and a new block as preheader of the scalar
66 /// loop (scalar.ph). See below for an illustration. It also adds a canonical
67 /// IV and its increment, using \p InductionTy and \p IVDL, and creates a
68 /// VPValue expression for the original trip count.
69 ///
70 /// [ ] <-- Plan's entry VPIRBasicBlock, wrapping the original loop's
71 /// / \ old preheader. Will contain iteration number check and SCEV
72 /// | | expansions.
73 /// | |
74 /// / v
75 /// | [ ] <-- vector loop bypass (may consist of multiple blocks) will be
76 /// | / | added later.
77 /// | / v
78 /// || [ ] <-- vector pre header.
79 /// |/ |
80 /// | v
81 /// | [ ] \ <-- plain CFG loop wrapping original loop to be vectorized.
82 /// | [ ]_|
83 /// | |
84 /// | v
85 /// | [ ] <--- middle-block with the branch to successors
86 /// | / |
87 /// | / |
88 /// | | v
89 /// \--->[ ] <--- scalar preheader (initial a VPBasicBlock, which will be
90 /// | | replaced later by a VPIRBasicBlock wrapping the scalar
91 /// | | preheader basic block.
92 /// | |
93 /// v <-- edge from middle to exit iff epilogue is not required.
94 /// | [ ] \
95 /// | [ ]_| <-- old scalar loop to handle remainder (scalar epilogue,
96 /// | | header wrapped in VPIRBasicBlock).
97 /// \ |
98 /// \ v
99 /// >[ ] <-- original loop exit block(s), wrapped in VPIRBasicBlocks.
100 LLVM_ABI_FOR_TEST static std::unique_ptr<VPlan>
101 buildVPlan0(Loop *TheLoop, LoopInfo &LI, Type *InductionTy, DebugLoc IVDL,
103
104 /// Update \p Plan to account for all early exits.
105 LLVM_ABI_FOR_TEST static void handleEarlyExits(VPlan &Plan,
106 bool HasUncountableExit);
107
108 /// If a check is needed to guard executing the scalar epilogue loop, it will
109 /// be added to the middle block.
110 LLVM_ABI_FOR_TEST static void addMiddleCheck(VPlan &Plan,
111 bool RequiresScalarEpilogueCheck,
112 bool TailFolded);
113
114 // Create a check to \p Plan to see if the vector loop should be executed.
115 static void addMinimumIterationCheck(
116 VPlan &Plan, ElementCount VF, unsigned UF,
117 ElementCount MinProfitableTripCount, bool RequiresScalarEpilogue,
118 bool TailFolded, bool CheckNeededWithTailFolding, Loop *OrigLoop,
120
121 /// Add a check to \p Plan to see if the epilogue vector loop should be
122 /// executed.
124 VPlan &Plan, Value *TripCount, Value *VectorTripCount,
125 bool RequiresScalarEpilogue, ElementCount EpilogueVF, unsigned EpilogueUF,
126 unsigned MainLoopStep, unsigned EpilogueLoopStep, ScalarEvolution &SE);
127
128 /// Replace loops in \p Plan's flat CFG with VPRegionBlocks, turning \p Plan's
129 /// flat CFG into a hierarchical CFG.
130 LLVM_ABI_FOR_TEST static void createLoopRegions(VPlan &Plan);
131
132 /// Wrap runtime check block \p CheckBlock in a VPIRBB and \p Cond in a
133 /// VPValue and connect the block to \p Plan, using the VPValue as branch
134 /// condition.
135 static void attachCheckBlock(VPlan &Plan, Value *Cond, BasicBlock *CheckBlock,
136 bool AddBranchWeights);
137
138 /// Replaces the VPInstructions in \p Plan with corresponding
139 /// widen recipes. Returns false if any VPInstructions could not be converted
140 /// to a wide recipe if needed.
142 VPlan &Plan,
144 GetIntOrFpInductionDescriptor,
145 const TargetLibraryInfo &TLI);
146
147 /// Try to have all users of fixed-order recurrences appear after the recipe
148 /// defining their previous value, by either sinking users or hoisting recipes
149 /// defining their previous value (and its operands). Then introduce
150 /// FirstOrderRecurrenceSplice VPInstructions to combine the value from the
151 /// recurrence phis and previous values.
152 /// \returns true if all users of fixed-order recurrences could be re-arranged
153 /// as needed or false if it is not possible. In the latter case, \p Plan is
154 /// not valid.
155 static bool adjustFixedOrderRecurrences(VPlan &Plan, VPBuilder &Builder);
156
157 /// Check if \p Plan contains any FMaxNum or FMinNum reductions. If they do,
158 /// try to update the vector loop to exit early if any input is NaN and resume
159 /// executing in the scalar loop to handle the NaNs there. Return false if
160 /// this attempt was unsuccessful.
161 static bool handleMaxMinNumReductions(VPlan &Plan);
162
163 /// Clear NSW/NUW flags from reduction instructions if necessary.
164 static void clearReductionWrapFlags(VPlan &Plan);
165
166 /// Explicitly unroll \p Plan by \p UF.
167 static void unrollByUF(VPlan &Plan, unsigned UF);
168
169 /// Replace each replicating VPReplicateRecipe and VPInstruction outside of
170 /// any replicate region in \p Plan with \p VF single-scalar recipes.
171 /// TODO: Also replicate VPScalarIVSteps and VPReplicateRecipes inside
172 /// replicate regions, thereby dissolving the latter.
173 static void replicateByVF(VPlan &Plan, ElementCount VF);
174
175 /// Optimize \p Plan based on \p BestVF and \p BestUF. This may restrict the
176 /// resulting plan to \p BestVF and \p BestUF.
177 static void optimizeForVFAndUF(VPlan &Plan, ElementCount BestVF,
178 unsigned BestUF,
180
181 /// Apply VPlan-to-VPlan optimizations to \p Plan, including induction recipe
182 /// optimizations, dead recipe removal, replicate region optimizations and
183 /// block merging.
184 LLVM_ABI_FOR_TEST static void optimize(VPlan &Plan);
185
186 /// Wrap predicated VPReplicateRecipes with a mask operand in an if-then
187 /// region block and remove the mask operand. Optimize the created regions by
188 /// iteratively sinking scalar operands into the region, followed by merging
189 /// regions until no improvements are remaining.
190 static void createAndOptimizeReplicateRegions(VPlan &Plan);
191
192 /// Replace (ICMP_ULE, wide canonical IV, backedge-taken-count) checks with an
193 /// (active-lane-mask recipe, wide canonical IV, trip-count). If \p
194 /// UseActiveLaneMaskForControlFlow is true, introduce an
195 /// VPActiveLaneMaskPHIRecipe. If \p DataAndControlFlowWithoutRuntimeCheck is
196 /// true, no minimum-iteration runtime check will be created (during skeleton
197 /// creation) and instead it is handled using active-lane-mask. \p
198 /// DataAndControlFlowWithoutRuntimeCheck implies \p
199 /// UseActiveLaneMaskForControlFlow.
200 static void addActiveLaneMask(VPlan &Plan,
201 bool UseActiveLaneMaskForControlFlow,
203
204 /// Insert truncates and extends for any truncated recipe. Redundant casts
205 /// will be folded later.
206 static void
209
210 /// Replace symbolic strides from \p StridesMap in \p Plan with constants when
211 /// possible.
212 static void
214 const DenseMap<Value *, const SCEV *> &StridesMap);
215
216 /// Drop poison flags from recipes that may generate a poison value that is
217 /// used after vectorization, even when their operands are not poison. Those
218 /// recipes meet the following conditions:
219 /// * Contribute to the address computation of a recipe generating a widen
220 /// memory load/store (VPWidenMemoryInstructionRecipe or
221 /// VPInterleaveRecipe).
222 /// * Such a widen memory load/store has at least one underlying Instruction
223 /// that is in a basic block that needs predication and after vectorization
224 /// the generated instruction won't be predicated.
225 /// Uses \p BlockNeedsPredication to check if a block needs predicating.
226 /// TODO: Replace BlockNeedsPredication callback with retrieving info from
227 /// VPlan directly.
228 static void dropPoisonGeneratingRecipes(
229 VPlan &Plan,
230 const std::function<bool(BasicBlock *)> &BlockNeedsPredication);
231
232 /// Add a VPEVLBasedIVPHIRecipe and related recipes to \p Plan and
233 /// replaces all uses except the canonical IV increment of
234 /// VPCanonicalIVPHIRecipe with a VPEVLBasedIVPHIRecipe.
235 /// VPCanonicalIVPHIRecipe is only used to control the loop after
236 /// this transformation.
237 static void
239 const std::optional<unsigned> &MaxEVLSafeElements);
240
241 // For each Interleave Group in \p InterleaveGroups replace the Recipes
242 // widening its memory instructions with a single VPInterleaveRecipe at its
243 // insertion point.
244 static void createInterleaveGroups(
245 VPlan &Plan,
247 &InterleaveGroups,
248 VPRecipeBuilder &RecipeBuilder, const bool &ScalarEpilogueAllowed);
249
250 /// Remove dead recipes from \p Plan.
251 static void removeDeadRecipes(VPlan &Plan);
252
253 /// Update \p Plan to account for the uncountable early exit from \p
254 /// EarlyExitingVPBB to \p EarlyExitVPBB by
255 /// * updating the condition exiting the loop via the latch to include the
256 /// early exit condition,
257 /// * splitting the original middle block to branch to the early exit block
258 /// conditionally - according to the early exit condition.
259 static void handleUncountableEarlyExit(VPBasicBlock *EarlyExitingVPBB,
260 VPBasicBlock *EarlyExitVPBB,
261 VPlan &Plan, VPBasicBlock *HeaderVPBB,
262 VPBasicBlock *LatchVPBB);
263
264 /// Replace loop regions with explicit CFG.
265 static void dissolveLoopRegions(VPlan &Plan);
266
267 /// Transform EVL loops to use variable-length stepping after region
268 /// dissolution.
269 ///
270 /// Once loop regions are replaced with explicit CFG, EVL loops can step with
271 /// variable vector lengths instead of fixed lengths. This transformation:
272 /// * Makes EVL-Phi concrete.
273 // * Removes CanonicalIV and increment.
274 /// * Replaces the exit condition from
275 /// (branch-on-count CanonicalIVInc, VectorTripCount)
276 /// to
277 /// (branch-on-cond eq AVLNext, 0)
278 static void canonicalizeEVLLoops(VPlan &Plan);
279
280 /// Lower abstract recipes to concrete ones, that can be codegen'd.
281 static void convertToConcreteRecipes(VPlan &Plan);
282
283 /// This function converts initial recipes to the abstract recipes and clamps
284 /// \p Range based on cost model for following optimizations and cost
285 /// estimations. The converted abstract recipes will lower to concrete
286 /// recipes before codegen.
287 static void convertToAbstractRecipes(VPlan &Plan, VPCostContext &Ctx,
288 VFRange &Range);
289
290 /// Perform instcombine-like simplifications on recipes in \p Plan.
291 static void simplifyRecipes(VPlan &Plan);
292
293 /// Remove BranchOnCond recipes with true or false conditions together with
294 /// removing dead edges to their successors.
295 static void removeBranchOnConst(VPlan &Plan);
296
297 /// Perform common-subexpression-elimination on \p Plan.
298 static void cse(VPlan &Plan);
299
300 /// If there's a single exit block, optimize its phi recipes that use exiting
301 /// IV values by feeding them precomputed end values instead, possibly taken
302 /// one step backwards.
303 static void
306 ScalarEvolution &SE);
307
308 /// Add explicit broadcasts for live-ins and VPValues defined in \p Plan's entry block if they are used as vectors.
309 static void materializeBroadcasts(VPlan &Plan);
310
311 // Materialize vector trip counts for constants early if it can simply be
312 // computed as (Original TC / VF * UF) * VF * UF.
313 static void
315 unsigned BestUF,
317
318 /// Materialize vector trip count computations to a set of VPInstructions.
319 static void materializeVectorTripCount(VPlan &Plan,
320 VPBasicBlock *VectorPHVPBB,
321 bool TailByMasking,
322 bool RequiresScalarEpilogue);
323
324 /// Materialize the backedge-taken count to be computed explicitly using
325 /// VPInstructions.
326 static void materializeBackedgeTakenCount(VPlan &Plan,
327 VPBasicBlock *VectorPH);
328
329 /// Add explicit Build[Struct]Vector recipes to Pack multiple scalar values
330 /// into vectors and Unpack recipes to extract scalars from vectors as
331 /// needed.
332 static void materializePacksAndUnpacks(VPlan &Plan);
333
334 /// Materialize VF and VFxUF to be computed explicitly using VPInstructions.
335 static void materializeVFAndVFxUF(VPlan &Plan, VPBasicBlock *VectorPH,
336 ElementCount VF);
337
338 /// Expand VPExpandSCEVRecipes in \p Plan's entry block. Each
339 /// VPExpandSCEVRecipe is replaced with a live-in wrapping the expanded IR
340 /// value. A mapping from SCEV expressions to their expanded IR value is
341 /// returned.
343 ScalarEvolution &SE);
344
345 /// Try to convert a plan with interleave groups with VF elements to a plan
346 /// with the interleave groups replaced by wide loads and stores processing VF
347 /// elements, if all transformed interleave groups access the full vector
348 /// width (checked via \o VectorRegWidth). This effectively is a very simple
349 /// form of loop-aware SLP, where we use interleave groups to identify
350 /// candidates.
351 static void narrowInterleaveGroups(VPlan &Plan, ElementCount VF,
352 TypeSize VectorRegWidth);
353
354 /// Predicate and linearize the control-flow in the only loop region of
355 /// \p Plan. If \p FoldTail is true, create a mask guarding the loop
356 /// header, otherwise use all-true for the header mask. Masks for blocks are
357 /// added to a block-to-mask map which is returned in order to be used later
358 /// for wide recipe construction. This argument is temporary and will be
359 /// removed in the future.
361 introduceMasksAndLinearize(VPlan &Plan, bool FoldTail);
362
363 /// Add branch weight metadata, if the \p Plan's middle block is terminated by
364 /// a BranchOnCond recipe.
365 static void
367 std::optional<unsigned> VScaleForTuning);
368
369 /// Create resume phis in the scalar preheader for first-order recurrences,
370 /// reductions and inductions, and update the VPIRInstructions wrapping the
371 /// original phis in the scalar header. End values for inductions are added to
372 /// \p IVEndValues.
373 static void addScalarResumePhis(VPlan &Plan, VPRecipeBuilder &Builder,
374 DenseMap<VPValue *, VPValue *> &IVEndValues);
375
376 /// Handle users in the exit block for first order reductions in the original
377 /// exit block. The penultimate value of recurrences is fed to their LCSSA phi
378 /// users in the original exit block using the VPIRInstruction wrapping to the
379 /// LCSSA phi.
381};
382
383} // namespace llvm
384
385#endif // LLVM_TRANSFORMS_VECTORIZE_VPLANTRANSFORMS_H
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
#define LLVM_ABI_FOR_TEST
Definition Compiler.h:218
static constexpr uint32_t MinItersBypassWeights[]
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
const SmallVectorImpl< MachineOperand > & Cond
This file declares the class VPlanVerifier, which contains utility functions to check the consistency...
This file contains the declarations of the Vectorization Plan base classes:
LLVM Basic Block Representation.
Definition BasicBlock.h:62
A debug info location.
Definition DebugLoc.h:124
A struct for saving information about induction variables.
The group of interleaved loads/stores sharing the same stride and close to each other.
Represents a single loop in the control flow graph.
Definition LoopInfo.h:40
This class implements a map that also provides access to all stored values in a deterministic order.
Definition MapVector.h:36
An interface layer with SCEV used to manage how we see SCEV expressions for values in the context of ...
The main scalar evolution driver.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
Provides information about what library functions are available for the current target.
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:45
VPBasicBlock serves as the leaf of the Hierarchical Control-Flow Graph.
Definition VPlan.h:3824
VPlan-based builder utility analogous to IRBuilder.
Helper class to create VPRecipies from IR instructions.
VPlan models a candidate for vectorization, encoding various decisions take to produce efficient outp...
Definition VPlan.h:4142
LLVM Value Representation.
Definition Value.h:75
An efficient, type-erasing, non-owning reference to a callable.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI_FOR_TEST cl::opt< bool > VerifyEachVPlan
LLVM_ABI_FOR_TEST bool verifyVPlanIsValid(const VPlan &Plan, bool VerifyLate=false)
Verify invariants for general VPlans.
LLVM_ABI_FOR_TEST cl::opt< bool > EnableWideActiveLaneMask
@ DataAndControlFlowWithoutRuntimeCheck
Use predicate to control both data and control flow, but modify the trip count so that a runtime over...
A range of powers-of-2 vectorization factors with fixed start and adjustable end.
Struct to hold various analysis needed for cost computations.
static void materializeBroadcasts(VPlan &Plan)
Add explicit broadcasts for live-ins and VPValues defined in Plan's entry block if they are used as v...
static void materializePacksAndUnpacks(VPlan &Plan)
Add explicit Build[Struct]Vector recipes to Pack multiple scalar values into vectors and Unpack recip...
static void materializeBackedgeTakenCount(VPlan &Plan, VPBasicBlock *VectorPH)
Materialize the backedge-taken count to be computed explicitly using VPInstructions.
static LLVM_ABI_FOR_TEST std::unique_ptr< VPlan > buildVPlan0(Loop *TheLoop, LoopInfo &LI, Type *InductionTy, DebugLoc IVDL, PredicatedScalarEvolution &PSE)
Create a base VPlan0, serving as the common starting point for all later candidates.
static void optimizeInductionExitUsers(VPlan &Plan, DenseMap< VPValue *, VPValue * > &EndValues, ScalarEvolution &SE)
If there's a single exit block, optimize its phi recipes that use exiting IV values by feeding them p...
static LLVM_ABI_FOR_TEST void handleEarlyExits(VPlan &Plan, bool HasUncountableExit)
Update Plan to account for all early exits.
static void addScalarResumePhis(VPlan &Plan, VPRecipeBuilder &Builder, DenseMap< VPValue *, VPValue * > &IVEndValues)
Create resume phis in the scalar preheader for first-order recurrences, reductions and inductions,...
static void canonicalizeEVLLoops(VPlan &Plan)
Transform EVL loops to use variable-length stepping after region dissolution.
static void dropPoisonGeneratingRecipes(VPlan &Plan, const std::function< bool(BasicBlock *)> &BlockNeedsPredication)
Drop poison flags from recipes that may generate a poison value that is used after vectorization,...
static void createAndOptimizeReplicateRegions(VPlan &Plan)
Wrap predicated VPReplicateRecipes with a mask operand in an if-then region block and remove the mask...
static void createInterleaveGroups(VPlan &Plan, const SmallPtrSetImpl< const InterleaveGroup< Instruction > * > &InterleaveGroups, VPRecipeBuilder &RecipeBuilder, const bool &ScalarEpilogueAllowed)
static bool runPass(bool(*Transform)(VPlan &, ArgsTy...), VPlan &Plan, typename std::remove_reference< ArgsTy >::type &...Args)
Helper to run a VPlan transform Transform on VPlan, forwarding extra arguments to the transform.
static void addBranchWeightToMiddleTerminator(VPlan &Plan, ElementCount VF, std::optional< unsigned > VScaleForTuning)
Add branch weight metadata, if the Plan's middle block is terminated by a BranchOnCond recipe.
static void narrowInterleaveGroups(VPlan &Plan, ElementCount VF, TypeSize VectorRegWidth)
Try to convert a plan with interleave groups with VF elements to a plan with the interleave groups re...
static void unrollByUF(VPlan &Plan, unsigned UF)
Explicitly unroll Plan by UF.
static DenseMap< const SCEV *, Value * > expandSCEVs(VPlan &Plan, ScalarEvolution &SE)
Expand VPExpandSCEVRecipes in Plan's entry block.
static void convertToConcreteRecipes(VPlan &Plan)
Lower abstract recipes to concrete ones, that can be codegen'd.
static void runPass(void(*Fn)(VPlan &, ArgsTy...), VPlan &Plan, typename std::remove_reference< ArgsTy >::type &...Args)
Helper to run a VPlan transform Transform on VPlan, forwarding extra arguments to the transform.
static void addMinimumIterationCheck(VPlan &Plan, ElementCount VF, unsigned UF, ElementCount MinProfitableTripCount, bool RequiresScalarEpilogue, bool TailFolded, bool CheckNeededWithTailFolding, Loop *OrigLoop, const uint32_t *MinItersBypassWeights, DebugLoc DL, ScalarEvolution &SE)
static void convertToAbstractRecipes(VPlan &Plan, VPCostContext &Ctx, VFRange &Range)
This function converts initial recipes to the abstract recipes and clamps Range based on cost model f...
static void materializeConstantVectorTripCount(VPlan &Plan, ElementCount BestVF, unsigned BestUF, PredicatedScalarEvolution &PSE)
static LLVM_ABI_FOR_TEST bool tryToConvertVPInstructionsToVPRecipes(VPlan &Plan, function_ref< const InductionDescriptor *(PHINode *)> GetIntOrFpInductionDescriptor, const TargetLibraryInfo &TLI)
Replaces the VPInstructions in Plan with corresponding widen recipes.
static void addExitUsersForFirstOrderRecurrences(VPlan &Plan, VFRange &Range)
Handle users in the exit block for first order reductions in the original exit block.
static DenseMap< VPBasicBlock *, VPValue * > introduceMasksAndLinearize(VPlan &Plan, bool FoldTail)
Predicate and linearize the control-flow in the only loop region of Plan.
static void addExplicitVectorLength(VPlan &Plan, const std::optional< unsigned > &MaxEVLSafeElements)
Add a VPEVLBasedIVPHIRecipe and related recipes to Plan and replaces all uses except the canonical IV...
static void replaceSymbolicStrides(VPlan &Plan, PredicatedScalarEvolution &PSE, const DenseMap< Value *, const SCEV * > &StridesMap)
Replace symbolic strides from StridesMap in Plan with constants when possible.
static bool handleMaxMinNumReductions(VPlan &Plan)
Check if Plan contains any FMaxNum or FMinNum reductions.
static void removeBranchOnConst(VPlan &Plan)
Remove BranchOnCond recipes with true or false conditions together with removing dead edges to their ...
static LLVM_ABI_FOR_TEST void createLoopRegions(VPlan &Plan)
Replace loops in Plan's flat CFG with VPRegionBlocks, turning Plan's flat CFG into a hierarchical CFG...
static void removeDeadRecipes(VPlan &Plan)
Remove dead recipes from Plan.
static void attachCheckBlock(VPlan &Plan, Value *Cond, BasicBlock *CheckBlock, bool AddBranchWeights)
Wrap runtime check block CheckBlock in a VPIRBB and Cond in a VPValue and connect the block to Plan,...
static void materializeVectorTripCount(VPlan &Plan, VPBasicBlock *VectorPHVPBB, bool TailByMasking, bool RequiresScalarEpilogue)
Materialize vector trip count computations to a set of VPInstructions.
static void simplifyRecipes(VPlan &Plan)
Perform instcombine-like simplifications on recipes in Plan.
static void handleUncountableEarlyExit(VPBasicBlock *EarlyExitingVPBB, VPBasicBlock *EarlyExitVPBB, VPlan &Plan, VPBasicBlock *HeaderVPBB, VPBasicBlock *LatchVPBB)
Update Plan to account for the uncountable early exit from EarlyExitingVPBB to EarlyExitVPBB by.
static void replicateByVF(VPlan &Plan, ElementCount VF)
Replace each replicating VPReplicateRecipe and VPInstruction outside of any replicate region in Plan ...
static void clearReductionWrapFlags(VPlan &Plan)
Clear NSW/NUW flags from reduction instructions if necessary.
static void cse(VPlan &Plan)
Perform common-subexpression-elimination on Plan.
static void addActiveLaneMask(VPlan &Plan, bool UseActiveLaneMaskForControlFlow, bool DataAndControlFlowWithoutRuntimeCheck)
Replace (ICMP_ULE, wide canonical IV, backedge-taken-count) checks with an (active-lane-mask recipe,...
static LLVM_ABI_FOR_TEST void optimize(VPlan &Plan)
Apply VPlan-to-VPlan optimizations to Plan, including induction recipe optimizations,...
static void dissolveLoopRegions(VPlan &Plan)
Replace loop regions with explicit CFG.
static void truncateToMinimalBitwidths(VPlan &Plan, const MapVector< Instruction *, uint64_t > &MinBWs)
Insert truncates and extends for any truncated recipe.
static bool adjustFixedOrderRecurrences(VPlan &Plan, VPBuilder &Builder)
Try to have all users of fixed-order recurrences appear after the recipe defining their previous valu...
static void optimizeForVFAndUF(VPlan &Plan, ElementCount BestVF, unsigned BestUF, PredicatedScalarEvolution &PSE)
Optimize Plan based on BestVF and BestUF.
static void materializeVFAndVFxUF(VPlan &Plan, VPBasicBlock *VectorPH, ElementCount VF)
Materialize VF and VFxUF to be computed explicitly using VPInstructions.
static void addMinimumVectorEpilogueIterationCheck(VPlan &Plan, Value *TripCount, Value *VectorTripCount, bool RequiresScalarEpilogue, ElementCount EpilogueVF, unsigned EpilogueUF, unsigned MainLoopStep, unsigned EpilogueLoopStep, ScalarEvolution &SE)
Add a check to Plan to see if the epilogue vector loop should be executed.
static LLVM_ABI_FOR_TEST void addMiddleCheck(VPlan &Plan, bool RequiresScalarEpilogueCheck, bool TailFolded)
If a check is needed to guard executing the scalar epilogue loop, it will be added to the middle bloc...