LLVM 23.0.0git
VPlanUtils.h
Go to the documentation of this file.
1//===- VPlanUtils.h - VPlan-related 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#ifndef LLVM_TRANSFORMS_VECTORIZE_VPLANUTILS_H
10#define LLVM_TRANSFORMS_VECTORIZE_VPLANUTILS_H
11
12#include "VPlan.h"
14
15namespace llvm {
16class MemoryLocation;
17class ScalarEvolution;
18class SCEV;
20} // namespace llvm
21
22namespace llvm {
23
24namespace vputils {
25/// Returns true if only the first lane of \p Def is used.
26bool onlyFirstLaneUsed(const VPValue *Def);
27
28/// Returns true if only the first part of \p Def is used.
29bool onlyFirstPartUsed(const VPValue *Def);
30
31/// Returns true if only scalar values of \p Def are used by all users.
32bool onlyScalarValuesUsed(const VPValue *Def);
33
34/// Get or create a VPValue that corresponds to the expansion of \p Expr. If \p
35/// Expr is a SCEVConstant or SCEVUnknown, return a VPValue wrapping the live-in
36/// value. Otherwise return a VPExpandSCEVRecipe to expand \p Expr. If \p Plan's
37/// pre-header already contains a recipe expanding \p Expr, return it. If not,
38/// create a new one.
40
41/// Return the SCEV expression for \p V. Returns SCEVCouldNotCompute if no
42/// SCEV expression could be constructed.
43const SCEV *getSCEVExprForVPValue(const VPValue *V,
45 const Loop *L = nullptr);
46
47/// Returns true if \p Addr is an address SCEV that can be passed to
48/// TTI::getAddressComputationCost, i.e. the address SCEV is loop invariant, an
49/// affine AddRec (i.e. induction ), or an add expression of such operands or a
50/// sign-extended AddRec.
51bool isAddressSCEVForCost(const SCEV *Addr, ScalarEvolution &SE, const Loop *L);
52
53/// Returns true if \p VPV is a single scalar, either because it produces the
54/// same value for all lanes or only has its first lane used.
55bool isSingleScalar(const VPValue *VPV);
56
57/// Return true if \p V is a header mask in \p Plan.
58bool isHeaderMask(const VPValue *V, const VPlan &Plan);
59
60/// Checks if \p V is uniform across all VF lanes and UF parts. It is considered
61/// as such if it is either loop invariant (defined outside the vector region)
62/// or its operands are known to be uniform across all VFs and UFs (e.g.
63/// VPDerivedIV or the canonical IV).
65
66/// Returns the header block of the first, top-level loop, or null if none
67/// exist.
69
70/// Get the VF scaling factor applied to the recipe's output, if the recipe has
71/// one.
73
74/// Return true if we do not know how to (mechanically) hoist or sink \p R.
75/// When sinking, passing \p Sinking = true ensures that assumes aren't sunk.
76/// Returns true for recipes that access memory.
77bool cannotHoistOrSinkRecipe(const VPRecipeBase &R, bool Sinking = false);
78
79/// Return the intrinsic ID underlying a call.
80template <typename Ty> Intrinsic::ID getIntrinsicID(const Ty *R) {
81 if (const auto *Intr = dyn_cast<VPWidenIntrinsicRecipe>(R))
82 return Intr->getVectorIntrinsicID();
83 if (const auto *Call = dyn_cast<VPWidenCallRecipe>(R))
84 return Call->getCalledScalarFunction()->getIntrinsicID();
85
86 auto GetCalleeIntrinsic = [&](VPValue *CalleeOp) -> Intrinsic::ID {
87 if (!isa<VPIRValue>(CalleeOp))
89 auto *F = cast<Function>(CalleeOp->getLiveInIRValue());
90 return F->getIntrinsicID();
91 };
92 if (const auto *Rep = dyn_cast<VPReplicateRecipe>(R))
93 if (Rep->getOpcode() == Instruction::Call)
94 // The mask is always the last operand if predicated.
95 return GetCalleeIntrinsic(
96 Rep->getOperand(Rep->getNumOperands() - 1 - Rep->isPredicated()));
97 if (const auto *VPI = dyn_cast<VPInstruction>(R))
98 if (VPI->getOpcode() == Instruction::Call)
99 return GetCalleeIntrinsic(VPI->getOperand(VPI->getNumOperands() - 1));
101}
102
103/// Returns the VPValue representing the uncountable exit comparison used by
104/// AnyOf if the recipes it depends on can be traced back to live-ins and
105/// the addresses (in GEP/PtrAdd form) of any (non-masked) load used in
106/// generating the values for the comparison. The recipes are stored in
107/// \p Recipes, and recipes forming an address for a load are also added to
108/// \p GEPs.
110std::optional<VPValue *>
113 VPBasicBlock *LatchVPBB);
114
115/// Return a MemoryLocation for \p R with noalias metadata populated from
116/// \p R, if the recipe is supported and std::nullopt otherwise. The pointer of
117/// the location is conservatively set to nullptr.
118std::optional<MemoryLocation> getMemoryLocation(const VPRecipeBase &R);
119
120/// Extracts and returns NoWrap and FastMath flags from the induction binop in
121/// \p ID.
124 return ID.getInductionBinOp()->getFastMathFlags();
125
127 ID.getInductionBinOp()))
128 return VPIRFlags::WrapFlagsTy(OBO->hasNoUnsignedWrap(),
129 OBO->hasNoSignedWrap());
130
132 "Expected int induction");
133 return VPIRFlags::WrapFlagsTy(false, false);
134}
135
136/// Search \p Start's users for a recipe satisfying \p Pred, looking through
137/// recipes with definitions.
138template <typename PredT>
139inline VPRecipeBase *findRecipe(VPValue *Start, PredT Pred) {
140 SetVector<VPValue *> Worklist;
141 Worklist.insert(Start);
142 for (unsigned I = 0; I != Worklist.size(); ++I) {
143 VPValue *Cur = Worklist[I];
144 auto *R = Cur->getDefiningRecipe();
145 if (!R)
146 continue;
147 if (Pred(R))
148 return R;
149 for (VPUser *U : Cur->users()) {
150 for (VPValue *V : cast<VPRecipeBase>(U)->definedValues())
151 Worklist.insert(V);
152 }
153 }
154 return nullptr;
155}
156
157/// Find the canonical IV increment of \p Plan's vector loop region. Returns
158/// nullptr if not found.
160
161/// Returns the GEP nowrap flags for \p Ptr, looking through pointer casts
162/// mirroring Value::stripPointerCasts.
164
165/// Returns true if \p V is used as part of the address of another load or
166/// store.
167bool isUsedByLoadStoreAddress(const VPValue *V);
168
169/// Find the ComputeReductionResult recipe for \p PhiR, looking through selects
170/// inserted for predicated reductions or tail folding.
172
173/// Collect the header mask with the pattern:
174/// (ICMP_ULE, WideCanonicalIV, backedge-taken-count)
175/// Note: If alias masking is enabled this will find:
176/// (AND, HeaderMask, AliasMask)
177/// TODO: Introduce explicit recipe for header-mask instead of searching
178/// the header-mask pattern manually.
180
181/// Finds the incoming alias-mask within the vector preheader.
183
184} // namespace vputils
185
186/// Lightweight SCEV-to-VPlan expander. Converts SCEV expressions into
187/// VPInstructions where possible, and returning nullptr for unsupported
188/// expressions (like adds, casts, min/max).
190 VPBuilder &Builder;
191 ScalarEvolution &SE;
192 DebugLoc DL;
193
194 /// Try to find a loop-invariant IR value in the plan's entry block whose
195 /// SCEV matches \p S. Returns the corresponding live-in VPValue, or nullptr
196 /// if none is found.
197 VPValue *tryToReuseIRValue(const SCEV *S);
198
199public:
201 : Builder(Builder), SE(SE), DL(DL) {}
202
203 /// Try to expand \p S into recipes and live-ins using the builder. Returns
204 /// nullptr if \p S cannot be expanded yet.
205 VPValue *tryToExpand(const SCEV *S);
206};
207//===----------------------------------------------------------------------===//
208// Utilities for modifying predecessors and successors of VPlan blocks.
209//===----------------------------------------------------------------------===//
210
211/// Class that provides utilities for VPBlockBases in VPlan.
213public:
214 VPBlockUtils() = delete;
215
216 /// Insert disconnected VPBlockBase \p NewBlock after \p BlockPtr. Add \p
217 /// NewBlock as successor of \p BlockPtr and \p BlockPtr as predecessor of \p
218 /// NewBlock, and propagate \p BlockPtr parent to \p NewBlock. \p BlockPtr's
219 /// successors are moved from \p BlockPtr to \p NewBlock. \p NewBlock must
220 /// have neither successors nor predecessors.
221 static void insertBlockAfter(VPBlockBase *NewBlock, VPBlockBase *BlockPtr) {
222 assert(!NewBlock->hasSuccessors() && !NewBlock->hasPredecessors() &&
223 "Can't insert new block with predecessors or successors.");
224 NewBlock->setParent(BlockPtr->getParent());
225 transferSuccessors(BlockPtr, NewBlock);
226 connectBlocks(BlockPtr, NewBlock);
227 }
228
229 /// Insert disconnected block \p NewBlock before \p Blockptr. First
230 /// disconnects all predecessors of \p BlockPtr and connects them to \p
231 /// NewBlock. Add \p NewBlock as predecessor of \p BlockPtr and \p BlockPtr as
232 /// successor of \p NewBlock.
233 static void insertBlockBefore(VPBlockBase *NewBlock, VPBlockBase *BlockPtr) {
234 assert(!NewBlock->hasSuccessors() && !NewBlock->hasPredecessors() &&
235 "Can't insert new block with predecessors or successors.");
236 NewBlock->setParent(BlockPtr->getParent());
237 for (VPBlockBase *Pred : to_vector(BlockPtr->predecessors())) {
238 Pred->replaceSuccessor(BlockPtr, NewBlock);
239 NewBlock->appendPredecessor(Pred);
240 }
241 BlockPtr->clearPredecessors();
242 connectBlocks(NewBlock, BlockPtr);
243 }
244
245 /// Insert disconnected VPBlockBases \p IfTrue and \p IfFalse after \p
246 /// BlockPtr. Add \p IfTrue and \p IfFalse as succesors of \p BlockPtr and \p
247 /// BlockPtr as predecessor of \p IfTrue and \p IfFalse. Propagate \p BlockPtr
248 /// parent to \p IfTrue and \p IfFalse. \p BlockPtr must have no successors
249 /// and \p IfTrue and \p IfFalse must have neither successors nor
250 /// predecessors.
251 static void insertTwoBlocksAfter(VPBlockBase *IfTrue, VPBlockBase *IfFalse,
252 VPBlockBase *BlockPtr) {
253 assert(!IfTrue->hasSuccessors() && "Can't insert IfTrue with successors.");
254 assert(!IfFalse->hasSuccessors() &&
255 "Can't insert IfFalse with successors.");
256 BlockPtr->setTwoSuccessors(IfTrue, IfFalse);
257 IfTrue->setPredecessors({BlockPtr});
258 IfFalse->setPredecessors({BlockPtr});
259 IfTrue->setParent(BlockPtr->getParent());
260 IfFalse->setParent(BlockPtr->getParent());
261 }
262
263 /// Connect VPBlockBases \p From and \p To bi-directionally. If \p PredIdx is
264 /// -1, append \p From to the predecessors of \p To, otherwise set \p To's
265 /// predecessor at \p PredIdx to \p From. If \p SuccIdx is -1, append \p To to
266 /// the successors of \p From, otherwise set \p From's successor at \p SuccIdx
267 /// to \p To. Both VPBlockBases must have the same parent, which can be null.
268 /// Both VPBlockBases can be already connected to other VPBlockBases.
269 static void connectBlocks(VPBlockBase *From, VPBlockBase *To,
270 unsigned PredIdx = -1u, unsigned SuccIdx = -1u) {
271 assert((From->getParent() == To->getParent()) &&
272 "Can't connect two block with different parents");
273
274 if (SuccIdx == -1u)
275 From->appendSuccessor(To);
276 else
277 From->getSuccessors()[SuccIdx] = To;
278
279 if (PredIdx == -1u)
280 To->appendPredecessor(From);
281 else
282 To->getPredecessors()[PredIdx] = From;
283 }
284
285 /// Disconnect VPBlockBases \p From and \p To bi-directionally. Remove \p To
286 /// from the successors of \p From and \p From from the predecessors of \p To.
287 static void disconnectBlocks(VPBlockBase *From, VPBlockBase *To) {
288 assert(To && "Successor to disconnect is null.");
289 From->removeSuccessor(To);
290 To->removePredecessor(From);
291 }
292
293 /// Reassociate all the blocks connected to \p Old so that they now point to
294 /// \p New.
295 static void reassociateBlocks(VPBlockBase *Old, VPBlockBase *New) {
296 for (auto *Pred : to_vector(Old->getPredecessors()))
297 Pred->replaceSuccessor(Old, New);
298 for (auto *Succ : to_vector(Old->getSuccessors()))
299 Succ->replacePredecessor(Old, New);
300 New->setPredecessors(Old->getPredecessors());
301 New->setSuccessors(Old->getSuccessors());
302 Old->clearPredecessors();
303 Old->clearSuccessors();
304 }
305
306 /// Transfer successors from \p Old to \p New. \p New must have no successors.
308 for (auto *Succ : Old->getSuccessors())
309 Succ->replacePredecessor(Old, New);
310 New->setSuccessors(Old->getSuccessors());
311 Old->clearSuccessors();
312 }
313
314 /// Clone the CFG for all nodes reachable from \p Entry, including cloning
315 /// the blocks and their recipes. Operands of cloned recipes will NOT be
316 /// updated. Remapping of operands must be done separately. Returns a pair
317 /// with the new entry and exiting blocks of the cloned region. If \p Entry
318 /// isn't part of a region, return nullptr for the exiting block.
319 static std::pair<VPBlockBase *, VPBlockBase *> cloneFrom(VPBlockBase *Entry);
320
321 /// Return an iterator range over \p Range which only includes \p BlockTy
322 /// blocks. The accesses are casted to \p BlockTy.
323 template <typename BlockTy, typename T> static auto blocksOnly(T &&Range) {
324 // Create BaseTy with correct const-ness based on BlockTy.
325 using BaseTy = std::conditional_t<std::is_const<BlockTy>::value,
326 const VPBlockBase, VPBlockBase>;
327
328 // We need to first create an iterator range over (const) BlocktTy & instead
329 // of (const) BlockTy * for filter_range to work properly.
330 auto Mapped =
331 map_range(Range, [](BaseTy *Block) -> BaseTy & { return *Block; });
333 Mapped, [](BaseTy &Block) { return isa<BlockTy>(&Block); });
334 return map_range(Filter, [](BaseTy &Block) -> BlockTy * {
335 return cast<BlockTy>(&Block);
336 });
337 }
338
339 /// Return an iterator range over \p Range with each block cast to \p
340 /// BlockTy. Unlike blocksOnly, all blocks in \p Range must be of type
341 /// \p BlockTy.
342 template <typename BlockTy, typename T> static auto blocksAs(T &&Range) {
343 // Create BaseTy with correct const-ness based on BlockTy.
344 using BaseTy = std::conditional_t<std::is_const<BlockTy>::value,
345 const VPBlockBase, VPBlockBase>;
346 return map_range(
347 Range, [](BaseTy *Block) -> BlockTy * { return cast<BlockTy>(Block); });
348 }
349
350 /// Returns the blocks between \p FirstBB and \p LastBB, where FirstBB
351 /// to LastBB forms a single-sucessor chain.
354 VPBasicBlock *LastBB);
355
356 /// Inserts \p BlockPtr on the edge between \p From and \p To. That is, update
357 /// \p From's successor to \p To to point to \p BlockPtr and \p To's
358 /// predecessor from \p From to \p BlockPtr. \p From and \p To are added to \p
359 /// BlockPtr's predecessors and successors respectively. There must be a
360 /// single edge between \p From and \p To.
361 static void insertOnEdge(VPBlockBase *From, VPBlockBase *To,
362 VPBlockBase *BlockPtr) {
363 unsigned SuccIdx = From->getIndexForSuccessor(To);
364 unsigned PredIx = To->getIndexForPredecessor(From);
365 VPBlockUtils::connectBlocks(From, BlockPtr, -1, SuccIdx);
366 VPBlockUtils::connectBlocks(BlockPtr, To, PredIx, -1);
367 }
368
369 /// Returns true if \p VPB is a loop header, based on regions or \p VPDT in
370 /// their absence.
371 static bool isHeader(const VPBlockBase *VPB, const VPDominatorTree &VPDT);
372
373 /// Returns true if \p VPB is a loop latch, using isHeader().
374 static bool isLatch(const VPBlockBase *VPB, const VPDominatorTree &VPDT);
375
376 /// Returns the header and latch of the outermost loop of \p Plan in plain
377 /// CFG form (before regions are formed).
378 static std::pair<VPBasicBlock *, VPBasicBlock *>
379 getPlainCFGHeaderAndLatch(const VPlan &Plan);
380
381 /// Returns the middle block of \p Plan in plain CFG form (before regions
382 /// are formed).
383 static VPBasicBlock *getPlainCFGMiddleBlock(const VPlan &Plan);
384};
385
386} // namespace llvm
387
388#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
#define LLVM_ABI_FOR_TEST
Definition Compiler.h:218
std::pair< BasicBlock *, unsigned > BlockTy
A pair of (basic block, score).
#define F(x, y, z)
Definition MD5.cpp:54
#define I(x, y, z)
Definition MD5.cpp:57
#define T
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
This file contains the declarations of the Vectorization Plan base classes:
A debug info location.
Definition DebugLoc.h:123
Represents flags for the getelementptr instruction/expression.
A struct for saving information about induction variables.
@ IK_FpInduction
Floating point induction variable.
@ IK_IntInduction
Integer induction variable. Step = C.
Represents a single loop in the control flow graph.
Definition LoopInfo.h:40
Representation for a specific memory location.
An interface layer with SCEV used to manage how we see SCEV expressions for values in the context of ...
This class represents an analyzed expression in the program.
The main scalar evolution driver.
A vector that has set insertion semantics.
Definition SetVector.h:57
size_type size() const
Determine the number of elements in the SetVector.
Definition SetVector.h:103
bool insert(const value_type &X)
Insert a new element into the SetVector.
Definition SetVector.h:151
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.
VPBasicBlock serves as the leaf of the Hierarchical Control-Flow Graph.
Definition VPlan.h:4295
VPBlockBase is the building block of the Hierarchical Control-Flow Graph.
Definition VPlan.h:93
VPRegionBlock * getParent()
Definition VPlan.h:185
iterator_range< VPBlockBase ** > predecessors()
Definition VPlan.h:219
bool hasPredecessors() const
Returns true if this block has any predecessors.
Definition VPlan.h:216
unsigned getIndexForSuccessor(const VPBlockBase *Succ) const
Returns the index for Succ in the blocks successor list.
Definition VPlan.h:349
void setPredecessors(ArrayRef< VPBlockBase * > NewPreds)
Set each VPBasicBlock in NewPreds as predecessor of this VPBlockBase.
Definition VPlan.h:305
unsigned getIndexForPredecessor(const VPBlockBase *Pred) const
Returns the index for Pred in the blocks predecessors list.
Definition VPlan.h:342
bool hasSuccessors() const
Returns true if this block has any successors.
Definition VPlan.h:214
const VPBlocksTy & getPredecessors() const
Definition VPlan.h:221
void clearSuccessors()
Remove all the successors of this block.
Definition VPlan.h:324
void setTwoSuccessors(VPBlockBase *IfTrue, VPBlockBase *IfFalse)
Set two given VPBlockBases IfTrue and IfFalse to be the two successors of this VPBlockBase.
Definition VPlan.h:296
void clearPredecessors()
Remove all the predecessor of this block.
Definition VPlan.h:321
void setParent(VPRegionBlock *P)
Definition VPlan.h:196
const VPBlocksTy & getSuccessors() const
Definition VPlan.h:210
static auto blocksAs(T &&Range)
Return an iterator range over Range with each block cast to BlockTy.
Definition VPlanUtils.h:342
static void insertBlockAfter(VPBlockBase *NewBlock, VPBlockBase *BlockPtr)
Insert disconnected VPBlockBase NewBlock after BlockPtr.
Definition VPlanUtils.h:221
static void insertOnEdge(VPBlockBase *From, VPBlockBase *To, VPBlockBase *BlockPtr)
Inserts BlockPtr on the edge between From and To.
Definition VPlanUtils.h:361
static bool isLatch(const VPBlockBase *VPB, const VPDominatorTree &VPDT)
Returns true if VPB is a loop latch, using isHeader().
static VPBasicBlock * getPlainCFGMiddleBlock(const VPlan &Plan)
Returns the middle block of Plan in plain CFG form (before regions are formed).
static bool isHeader(const VPBlockBase *VPB, const VPDominatorTree &VPDT)
Returns true if VPB is a loop header, based on regions or VPDT in their absence.
static void insertTwoBlocksAfter(VPBlockBase *IfTrue, VPBlockBase *IfFalse, VPBlockBase *BlockPtr)
Insert disconnected VPBlockBases IfTrue and IfFalse after BlockPtr.
Definition VPlanUtils.h:251
static void connectBlocks(VPBlockBase *From, VPBlockBase *To, unsigned PredIdx=-1u, unsigned SuccIdx=-1u)
Connect VPBlockBases From and To bi-directionally.
Definition VPlanUtils.h:269
static void disconnectBlocks(VPBlockBase *From, VPBlockBase *To)
Disconnect VPBlockBases From and To bi-directionally.
Definition VPlanUtils.h:287
static void reassociateBlocks(VPBlockBase *Old, VPBlockBase *New)
Reassociate all the blocks connected to Old so that they now point to New.
Definition VPlanUtils.h:295
static void insertBlockBefore(VPBlockBase *NewBlock, VPBlockBase *BlockPtr)
Insert disconnected block NewBlock before Blockptr.
Definition VPlanUtils.h:233
static auto blocksOnly(T &&Range)
Return an iterator range over Range which only includes BlockTy blocks.
Definition VPlanUtils.h:323
static std::pair< VPBasicBlock *, VPBasicBlock * > getPlainCFGHeaderAndLatch(const VPlan &Plan)
Returns the header and latch of the outermost loop of Plan in plain CFG form (before regions are form...
static void transferSuccessors(VPBlockBase *Old, VPBlockBase *New)
Transfer successors from Old to New. New must have no successors.
Definition VPlanUtils.h:307
static SmallVector< VPBasicBlock * > blocksInSingleSuccessorChainBetween(VPBasicBlock *FirstBB, VPBasicBlock *LastBB)
Returns the blocks between FirstBB and LastBB, where FirstBB to LastBB forms a single-sucessor chain.
static std::pair< VPBlockBase *, VPBlockBase * > cloneFrom(VPBlockBase *Entry)
Clone the CFG for all nodes reachable from Entry, including cloning the blocks and their recipes.
Definition VPlan.cpp:688
VPlan-based builder utility analogous to IRBuilder.
Template specialization of the standard LLVM dominator tree utility for VPBlockBases.
Class to record and manage LLVM IR flags.
Definition VPlan.h:700
This is a concrete Recipe that models a single VPlan-level instruction.
Definition VPlan.h:1231
VPRecipeBase is a base class modeling a sequence of one or more output IR instructions.
Definition VPlan.h:401
A recipe for handling reduction phis.
Definition VPlan.h:2805
VPSCEVExpander(VPBuilder &Builder, ScalarEvolution &SE, DebugLoc DL={})
Definition VPlanUtils.h:200
VPValue * tryToExpand(const SCEV *S)
Try to expand S into recipes and live-ins using the builder.
VPSingleDefRecipe is a base class for recipes that model a sequence of one or more output IR that def...
Definition VPlan.h:614
This class augments VPValue with operands which provide the inverse def-use edges from VPValue's user...
Definition VPlanValue.h:384
This is the base class of the VPlan Def/Use graph, used for modeling the data flow into,...
Definition VPlanValue.h:50
VPRecipeBase * getDefiningRecipe()
Returns the recipe defining this VPValue or nullptr if it is not defined by a recipe,...
Definition VPlan.cpp:130
user_range users()
Definition VPlanValue.h:157
VPlan models a candidate for vectorization, encoding various decisions take to produce efficient outp...
Definition VPlan.h:4653
CallInst * Call
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition CallingConv.h:24
bool isSingleScalar(const VPValue *VPV)
Returns true if VPV is a single scalar, either because it produces the same value for all lanes or on...
VPValue * getOrCreateVPValueForSCEVExpr(VPlan &Plan, const SCEV *Expr)
Get or create a VPValue that corresponds to the expansion of Expr.
bool cannotHoistOrSinkRecipe(const VPRecipeBase &R, bool Sinking=false)
Return true if we do not know how to (mechanically) hoist or sink R.
VPBasicBlock * getFirstLoopHeader(VPlan &Plan, VPDominatorTree &VPDT)
Returns the header block of the first, top-level loop, or null if none exist.
bool isAddressSCEVForCost(const SCEV *Addr, ScalarEvolution &SE, const Loop *L)
Returns true if Addr is an address SCEV that can be passed to TTI::getAddressComputationCost,...
bool onlyFirstPartUsed(const VPValue *Def)
Returns true if only the first part of Def is used.
Intrinsic::ID getIntrinsicID(const Ty *R)
Return the intrinsic ID underlying a call.
Definition VPlanUtils.h:80
VPInstruction * findComputeReductionResult(VPReductionPHIRecipe *PhiR)
Find the ComputeReductionResult recipe for PhiR, looking through selects inserted for predicated redu...
VPInstruction * findCanonicalIVIncrement(VPlan &Plan)
Find the canonical IV increment of Plan's vector loop region.
std::optional< MemoryLocation > getMemoryLocation(const VPRecipeBase &R)
Return a MemoryLocation for R with noalias metadata populated from R, if the recipe is supported and ...
bool onlyFirstLaneUsed(const VPValue *Def)
Returns true if only the first lane of Def is used.
VPValue * findIncomingAliasMask(const VPlan &Plan)
Finds the incoming alias-mask within the vector preheader.
VPIRFlags getFlagsFromIndDesc(const InductionDescriptor &ID)
Extracts and returns NoWrap and FastMath flags from the induction binop in ID.
Definition VPlanUtils.h:122
VPRecipeBase * findRecipe(VPValue *Start, PredT Pred)
Search Start's users for a recipe satisfying Pred, looking through recipes with definitions.
Definition VPlanUtils.h:139
VPSingleDefRecipe * findHeaderMask(VPlan &Plan)
Collect the header mask with the pattern: (ICMP_ULE, WideCanonicalIV, backedge-taken-count) Note: If ...
bool onlyScalarValuesUsed(const VPValue *Def)
Returns true if only scalar values of Def are used by all users.
bool isUniformAcrossVFsAndUFs(const VPValue *V)
Checks if V is uniform across all VF lanes and UF parts.
bool isUsedByLoadStoreAddress(const VPValue *V)
Returns true if V is used as part of the address of another load or store.
LLVM_ABI_FOR_TEST std::optional< VPValue * > getRecipesForUncountableExit(SmallVectorImpl< VPInstruction * > &Recipes, SmallVectorImpl< VPInstruction * > &GEPs, VPBasicBlock *LatchVPBB)
Returns the VPValue representing the uncountable exit comparison used by AnyOf if the recipes it depe...
GEPNoWrapFlags getGEPFlagsForPtr(VPValue *Ptr)
Returns the GEP nowrap flags for Ptr, looking through pointer casts mirroring Value::stripPointerCast...
const SCEV * getSCEVExprForVPValue(const VPValue *V, PredicatedScalarEvolution &PSE, const Loop *L=nullptr)
Return the SCEV expression for V.
unsigned getVFScaleFactor(VPRecipeBase *R)
Get the VF scaling factor applied to the recipe's output, if the recipe has one.
bool isHeaderMask(const VPValue *V, const VPlan &Plan)
Return true if V is a header mask in Plan.
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
auto dyn_cast_if_present(const Y &Val)
dyn_cast_if_present<X> - Functionally identical to dyn_cast, except that a null (or none in the case ...
Definition Casting.h:732
auto map_range(ContainerTy &&C, FuncTy F)
Return a range that applies F to the elements of C.
Definition STLExtras.h:365
SmallVector< ValueTypeFromRangeType< R >, Size > to_vector(R &&Range)
Given a range of type R, iterate the entire range and return a SmallVector with elements of the vecto...
iterator_range< filter_iterator< detail::IterOfRange< RangeT >, PredicateT > > make_filter_range(RangeT &&Range, PredicateT Pred)
Convenience function that takes a range of elements and a predicate, and return a new filter_iterator...
Definition STLExtras.h:551
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
Definition Casting.h:547
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559