LLVM 24.0.0git
VPlanHelpers.h
Go to the documentation of this file.
1//===- VPlanHelpers.h - VPlan-related auxiliary helpers -------------------===//
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 contains the declarations of different VPlan-related auxiliary
11/// helpers.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_TRANSFORMS_VECTORIZE_VPLANHELPERS_H
16#define LLVM_TRANSFORMS_VECTORIZE_VPLANHELPERS_H
17
18#include "VPlanAnalysis.h"
19#include "VPlanDominatorTree.h"
20#include "llvm/ADT/DenseMap.h"
25#include "llvm/IR/DebugLoc.h"
28
29namespace llvm {
30
31class AssumptionCache;
32class BasicBlock;
33class DominatorTree;
34class Function;
35class IRBuilderBase;
36class LoopInfo;
37class Type;
39class VPBasicBlock;
40class VPRegionBlock;
41class VPlan;
42class VPSlotTracker;
43class Value;
44struct VectorizeOptions;
45
46namespace Intrinsic {
47typedef unsigned ID;
48}
49
50/// A range of powers-of-2 vectorization factors with fixed start and
51/// adjustable end. The range includes start and excludes end, e.g.,:
52/// [1, 16) = {1, 2, 4, 8}
53struct VFRange {
54 // A power of 2.
56
57 // A power of 2. If End <= Start range is empty.
59
60 bool isEmpty() const {
61 return End.getKnownMinValue() <= Start.getKnownMinValue();
62 }
63
65 : Start(Start), End(End) {
66 assert(Start.isScalable() == End.isScalable() &&
67 "Both Start and End should have the same scalable flag");
68 assert(Start.isPowerOf2() && "Expected Start to be a power of 2");
69 assert(End.isPowerOf2() && "Expected End to be a power of 2");
70 }
71
72 /// Iterator to iterate over vectorization factors in a VFRange.
74 : public iterator_facade_base<iterator, std::forward_iterator_tag,
75 ElementCount> {
76 ElementCount VF;
77
78 public:
79 iterator(ElementCount VF) : VF(VF) {}
80
81 bool operator==(const iterator &Other) const { return VF == Other.VF; }
82
83 ElementCount operator*() const { return VF; }
84
86 VF *= 2;
87 return *this;
88 }
89 };
90
93 assert(End.isPowerOf2());
94 return iterator(End);
95 }
96};
97
98/// In what follows, the term "input IR" refers to code that is fed into the
99/// vectorizer whereas the term "output IR" refers to code that is generated by
100/// the vectorizer.
101
102/// VPLane provides a way to access lanes in both fixed width and scalable
103/// vectors, where for the latter the lane index sometimes needs calculating
104/// as a runtime expression.
105class VPLane {
106public:
107 /// Kind describes how to interpret Lane.
108 enum class Kind : uint8_t {
109 /// For First, Lane is the index into the first N elements of a
110 /// fixed-vector <N x <ElTy>> or a scalable vector <vscale x N x <ElTy>>.
112 /// For ScalableLast, Lane is the offset from the start of the last
113 /// N-element subvector in a scalable vector <vscale x N x <ElTy>>. For
114 /// example, a Lane of 0 corresponds to lane `(vscale - 1) * N`, a Lane of
115 /// 1 corresponds to `((vscale - 1) * N) + 1`, etc.
117 };
118
119private:
120 /// in [0..VF)
121 unsigned Lane;
122
123 /// Indicates how the Lane should be interpreted, as described above.
124 Kind LaneKind = Kind::First;
125
126public:
127 VPLane(unsigned Lane) : Lane(Lane) {}
128 VPLane(unsigned Lane, Kind LaneKind) : Lane(Lane), LaneKind(LaneKind) {}
129
131
132 static VPLane getLaneFromEnd(const ElementCount &VF, unsigned Offset) {
133 assert(Offset > 0 && Offset <= VF.getKnownMinValue() &&
134 "trying to extract with invalid offset");
135 unsigned LaneOffset = VF.getKnownMinValue() - Offset;
136 Kind LaneKind;
137 if (VF.isScalable())
138 // In this case 'LaneOffset' refers to the offset from the start of the
139 // last subvector with VF.getKnownMinValue() elements.
141 else
142 LaneKind = VPLane::Kind::First;
143 return VPLane(LaneOffset, LaneKind);
144 }
145
147 return getLaneFromEnd(VF, 1);
148 }
149
150 /// Returns an expression describing the lane index that can be used at
151 /// runtime.
152 Value *getAsRuntimeExpr(IRBuilderBase &Builder, const ElementCount &VF) const;
153
154 /// Returns true if this is the first lane of the whole vector.
155 bool isFirstLane() const { return Lane == 0 && LaneKind == Kind::First; }
156
157 /// Maps the lane to a cache index based on \p VF.
158 unsigned mapToCacheIndex(const ElementCount &VF) const {
159 switch (LaneKind) {
161 assert(VF.isScalable() && Lane < VF.getKnownMinValue() &&
162 "ScalableLast can only be used with scalable VFs");
163 return VF.getKnownMinValue() + Lane;
164 default:
165 assert(Lane < VF.getKnownMinValue() &&
166 "Cannot extract lane larger than VF");
167 return Lane;
168 }
169 }
170};
171
172/// VPTransformState holds information passed down when "executing" a VPlan,
173/// needed for generating the output IR.
179 /// Target Transform Info.
181
182 /// The chosen Vectorization Factor of the loop being vectorized.
184
185 struct DataState {
186 // Each value from the original loop, when vectorized, is represented by a
187 // vector value in the map.
189
192
193 /// Get the generated vector Value for a given VPValue \p Def if
194 /// \p NeedsSingleScalar is false, otherwise return the generated scalar.
195 /// \See set.
196 Value *get(const VPValue *Def, bool NeedsSingleScalar = false);
197
198 /// Get the generated Value for a given VPValue and given Part and Lane.
199 Value *get(const VPValue *Def, const VPLane &Lane);
200
201 bool hasVectorValue(const VPValue *Def) {
202 return Data.VPV2Vector.contains(Def);
203 }
204
205 bool hasScalarValue(const VPValue *Def, VPLane Lane) {
206 auto I = Data.VPV2Scalars.find(Def);
207 if (I == Data.VPV2Scalars.end())
208 return false;
209 unsigned CacheIdx = Lane.mapToCacheIndex(VF);
210 return CacheIdx < I->second.size() && I->second[CacheIdx];
211 }
212
213 /// Set the generated vector Value for a given VPValue, if \p
214 /// IsScalar is false. If \p IsScalar is true, set the scalar in lane 0.
215 void set(const VPValue *Def, Value *V, bool IsScalar = false) {
216 if (IsScalar) {
217 set(Def, V, VPLane(0));
218 return;
219 }
220 assert((VF.isScalar() || isVectorizedTy(V->getType())) &&
221 "scalar values must be stored as (0, 0)");
222 Data.VPV2Vector[Def] = V;
223 }
224
225 /// Set the generated scalar \p V for \p Def and the given \p Lane.
226 void set(const VPValue *Def, Value *V, const VPLane &Lane) {
227 auto &Scalars = Data.VPV2Scalars[Def];
228 unsigned CacheIdx = Lane.mapToCacheIndex(VF);
229 if (Scalars.size() <= CacheIdx)
230 Scalars.resize(CacheIdx + 1);
231 assert(!Scalars[CacheIdx] && "should overwrite existing value");
232 Scalars[CacheIdx] = V;
233 }
234
235 /// Set the debug location in the builder using the debug location \p DL.
237
238 /// Add the backedge (latch) incoming value to the canonical, reduction and
239 /// first-order recurrence phis in all loop headers state's plan, after
240 /// the loop body has been generated.
241 void fixupHeaderPhis();
242
243 /// Hold state information used when constructing the CFG of the output IR,
244 /// traversing the VPBasicBlocks and generating corresponding IR BasicBlocks.
245 struct CFGState {
246 /// The previous IR BasicBlock created or used. Initially set to the new
247 /// header BasicBlock.
248 BasicBlock *PrevBB = nullptr;
249
250 /// The last IR BasicBlock in the output IR. Set to the exit block of the
251 /// vector loop.
252 BasicBlock *ExitBB = nullptr;
253
254 /// A mapping of each VPBasicBlock to the corresponding BasicBlock. In case
255 /// of replication, maps the BasicBlock of the last replica created.
257
258 /// Updater for the DominatorTree.
260
262 : DTU(DT, DomTreeUpdater::UpdateStrategy::Lazy) {}
264
265 /// Hold a pointer to LoopInfo to register new basic blocks in the loop.
267
268 /// Hold a pointer to AssumptionCache to register new assumptions after
269 /// replicating assume calls.
271
272 /// Hold a reference to the IRBuilder used to generate output IR code.
274
275 /// Pointer to the VPlan code is generated for.
277
278 /// The parent loop object for the current scope, or nullptr.
280
281 /// VPlan-based dominator tree.
283};
284
285/// Struct to hold various analysis needed for cost computations.
287 const VectorizeOptions &Opts;
296 const Loop *L;
297
298 /// Number of predicated stores in the VPlan, computed on demand.
299 std::optional<unsigned> NumPredStores;
300
301 VPCostContext(const TargetLibraryInfo &TLI, const VPlan &Plan,
303 bool ReusePrintingSlotTracker = false);
304
305 /// Return the cost for \p UI with \p VF using the legacy cost model as
306 /// fallback until computing the cost of all recipes migrates to VPlan.
308
309 /// Return true if the cost for \p UI shouldn't be computed, e.g. because it
310 /// has already been pre-computed.
311 bool skipCostComputation(Instruction *UI, bool IsVector) const;
312
313 /// Mark the widening decision for \p I at \p VF as invalidated since a VPlan
314 /// transform replaced the original recipe.
316
317 /// \returns how much the cost of a block executing with recorded frequency
318 /// \p Freq should be divided by.
319 uint64_t getCostDivisor(std::optional<VPExecutionFrequency> Freq) const;
320
321 /// Returns true if \p I is known to be scalarized at \p VF.
323
324 /// Returns true if the vector loop body of \p Plan is known to execute at
325 /// most once at \p VF, i.e. its trip count is a constant not greater than
326 /// \p VF. Currently ignores UF.
327 static bool executesAtMostOnce(const VPlan &Plan, ElementCount VF);
328
329 /// Forwards to LoopVectorizationCostModel::isMaskRequired.
330 bool isMaskRequired(Instruction *I) const;
331
332 /// Returns the OperandInfo for \p V, if it is a live-in.
334
335 /// Estimate the overhead of scalarizing a recipe with result type \p ResultTy
336 /// and \p Operands with \p VF. This is a convenience wrapper for the
337 /// type-based getScalarizationOverhead API. \p VIC provides context about
338 /// whether the scalarization is for a load/store operation. If \p
339 /// AlwaysIncludeReplicatingR is true, always compute the cost of scalarizing
340 /// replicating operands.
344 bool AlwaysIncludeReplicatingR = false);
345
346 /// Returns true if an artificially high cost for emulated masked memrefs
347 /// should be used.
349
350 /// Returns true if \p ID is a pseudo intrinsic that is dropped via
351 /// scalarization rather than widened.
352 static bool isFreeScalarIntrinsic(Intrinsic::ID ID);
353
354#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
355 /// Return a VPSlotTracker to re-use for printing, lazily constructing it on
356 /// first use. Returns nullptr if slot-tracker re-use was not requested at
357 /// construction.
359
360private:
361 /// VPlan to build the printing VPSlotTracker for, or nullptr if slot-tracker
362 /// re-use was not requested.
363 const VPlan *PlanForSlotTracker = nullptr;
364
365 /// SlotTracker to re-use when printing, lazily constructed by getSlotTracker.
366 std::unique_ptr<VPSlotTracker> SlotTracker;
367#endif
368};
369
370/// This class can be used to assign names to VPValues. For VPValues without
371/// underlying value, assign consecutive numbers and use those as names (wrapped
372/// in vp<>). Otherwise, use the name from the underlying value (wrapped in
373/// ir<>), appending a .V version number if there are multiple uses of the same
374/// name. Allows querying names for VPValues for printing, similar to the
375/// ModuleSlotTracker for IR values.
377 /// Keep track of versioned names assigned to VPValues with underlying IR
378 /// values.
380 /// Keep track of the next number to use to version the base name.
381 StringMap<unsigned> BaseName2Version;
382
383 /// Number to assign to the next VPValue without underlying value.
384 unsigned NextSlot = 0;
385
386 /// Lazily created ModuleSlotTracker, used only when unnamed IR instructions
387 /// require slot tracking.
388 std::unique_ptr<ModuleSlotTracker> MST;
389
390 /// Cached metadata kind names from the Module's LLVMContext.
392
393 /// Cached Function pointer for printing names and metadata.
394 const Function *F = nullptr;
395
396 void assignName(const VPValue *V);
397 LLVM_ABI_FOR_TEST void assignNames(const VPlan &Plan);
398 void assignNames(const VPBasicBlock *VPBB);
399 std::string getName(const Value *V);
400
401 /// Lazily create the ModuleSlotTracker.
402 ModuleSlotTracker &getOrCreateMST();
403
404public:
405 VPSlotTracker(const VPlan *Plan = nullptr) {
406 if (Plan) {
407 if (auto *ScalarHeader = Plan->getScalarHeader()) {
408 const BasicBlock *ScalarHeaderIRBB = ScalarHeader->getIRBasicBlock();
409 F = ScalarHeaderIRBB->getParent();
410 }
411 assignNames(*Plan);
412 }
413 }
414
415 /// Returns the name assigned to \p V, if there is one, otherwise try to
416 /// construct one from the underlying value, if there's one; else return
417 /// <badref>.
418 std::string getOrCreateName(const VPValue *V) const;
419
420 /// Returns the cached metadata kind names.
422 const Module *M = getModule();
423 if (MDNames.empty() && M)
424 M->getContext().getMDKindNames(MDNames);
425 return MDNames;
426 }
427
428 /// Print a reference to metadata node \p N to \p O.
430
431 /// Returns the module the plan operates on, if any.
432 const Module *getModule() const { return F ? F->getParent() : nullptr; }
433};
434
435#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
436/// VPlanPrinter prints a given VPlan to a given output stream. The printing is
437/// indented and follows the dot format.
439 raw_ostream &OS;
440 const VPlan &Plan;
441 unsigned Depth = 0;
442 unsigned TabWidth = 2;
443 std::string Indent;
444 unsigned BID = 0;
446
447 VPSlotTracker SlotTracker;
448
449 /// Handle indentation.
450 void bumpIndent(int b) { Indent = std::string((Depth += b) * TabWidth, ' '); }
451
452 /// Print a given \p Block of the Plan.
453 void dumpBlock(const VPBlockBase *Block);
454
455 /// Print the information related to the CFG edges going out of a given
456 /// \p Block, followed by printing the successor blocks themselves.
457 void dumpEdges(const VPBlockBase *Block);
458
459 /// Print a given \p BasicBlock, including its VPRecipes, followed by printing
460 /// its successor blocks.
461 void dumpBasicBlock(const VPBasicBlock *BasicBlock);
462
463 /// Print a given \p Region of the Plan.
464 void dumpRegion(const VPRegionBlock *Region);
465
466 unsigned getOrCreateBID(const VPBlockBase *Block) {
467 return BlockID.count(Block) ? BlockID[Block] : BlockID[Block] = BID++;
468 }
469
470 Twine getUID(const VPBlockBase *Block);
471
472 /// Print the information related to a CFG edge between two VPBlockBases.
473 void drawEdge(const VPBlockBase *From, const VPBlockBase *To, bool Hidden,
474 const Twine &Label);
475
476public:
478 : OS(O), Plan(P), SlotTracker(&P) {}
479
480 LLVM_DUMP_METHOD void dump();
481};
482#endif
483
484/// Check if a constant \p CI can be safely treated as having been extended
485/// from a narrower type with the given extension kind.
486bool canConstantBeExtended(const APInt *C, Type *NarrowType,
488} // end namespace llvm
489
490#endif // LLVM_TRANSFORMS_VECTORIZE_VPLAN_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
uint64_t uint64_t
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
Definition Compiler.h:702
#define LLVM_ABI_FOR_TEST
Definition Compiler.h:216
This file defines the DenseMap class.
Flatten the CFG
This file defines an InstructionCost class that is used when calculating the cost of an instruction,...
#define I(x, y, z)
Definition MD5.cpp:57
#define P(N)
SI Fold Operands
This file defines the SmallPtrSet class.
This file defines the SmallVector class.
This pass exposes codegen information to IR-level passes.
This file implements dominator tree analysis for a single level of a VPlan's H-CFG.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
A cache of @llvm.assume calls within a function.
LLVM Basic Block Representation.
Definition BasicBlock.h:61
const Function * getParent() const
Return the enclosing method, or null if none.
Definition BasicBlock.h:212
A debug info location.
Definition DebugLoc.h:126
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Definition Dominators.h:122
Common base class shared among various IRBuilders.
Definition IRBuilder.h:111
This is an important class for using LLVM in a threaded context.
Definition LLVMContext.h:76
LoopVectorizationCostModel - estimates the expected speedups due to vectorization.
Represents a single loop in the control flow graph.
Definition LoopInfo.h:40
Metadata node.
Definition Metadata.h:1087
Manage lifetime of a slot tracker for printing IR.
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:68
An interface layer with SCEV used to manage how we see SCEV expressions for values in the context of ...
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Definition StringMap.h:129
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.
TargetCostKind
The kind of cost model.
llvm::VectorInstrContext VectorInstrContext
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition Twine.h:82
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
Iterator to iterate over vectorization factors in a VFRange.
ElementCount operator*() const
iterator(ElementCount VF)
bool operator==(const iterator &Other) const
Holds state needed to make cost decisions before computing costs per-VF, including the maximum VFs.
VPBasicBlock serves as the leaf of the Hierarchical Control-Flow Graph.
Definition VPlan.h:4509
VPBlockBase is the building block of the Hierarchical Control-Flow Graph.
Definition VPlan.h:79
Template specialization of the standard LLVM dominator tree utility for VPBlockBases.
In what follows, the term "input IR" refers to code that is fed into the vectorizer whereas the term ...
static VPLane getLastLaneForVF(const ElementCount &VF)
Value * getAsRuntimeExpr(IRBuilderBase &Builder, const ElementCount &VF) const
Returns an expression describing the lane index that can be used at runtime.
Definition VPlan.cpp:77
VPLane(unsigned Lane, Kind LaneKind)
static VPLane getLaneFromEnd(const ElementCount &VF, unsigned Offset)
bool isFirstLane() const
Returns true if this is the first lane of the whole vector.
VPLane(unsigned Lane)
static VPLane getFirstLane()
Kind
Kind describes how to interpret Lane.
@ ScalableLast
For ScalableLast, Lane is the offset from the start of the last N-element subvector in a scalable vec...
@ First
For First, Lane is the index into the first N elements of a fixed-vector <N x <ElTy>> or a scalable v...
unsigned mapToCacheIndex(const ElementCount &VF) const
Maps the lane to a cache index based on VF.
VPRegionBlock represents a collection of VPBasicBlocks and VPRegionBlocks which form a Single-Entry-S...
Definition VPlan.h:4740
VPReplicateRecipe replicates a given instruction producing multiple scalar copies of the original sca...
Definition VPlan.h:3458
This class can be used to assign names to VPValues.
ArrayRef< StringRef > getMDNames()
Returns the cached metadata kind names.
std::string getOrCreateName(const VPValue *V) const
Returns the name assigned to V, if there is one, otherwise try to construct one from the underlying v...
Definition VPlan.cpp:1615
const Module * getModule() const
Returns the module the plan operates on, if any.
void printMetadataAsOperand(raw_ostream &O, const MDNode *N)
Print a reference to metadata node N to O.
Definition VPlan.cpp:1611
VPSlotTracker(const VPlan *Plan=nullptr)
This is the base class of the VPlan Def/Use graph, used for modeling the data flow into,...
Definition VPlanValue.h:50
VPlanPrinter(raw_ostream &O, const VPlan &P)
LLVM_DUMP_METHOD void dump()
Definition VPlan.cpp:1327
VPlan models a candidate for vectorization, encoding various decisions take to produce efficient outp...
Definition VPlan.h:4927
VPIRBasicBlock * getScalarHeader() const
Return the VPIRBasicBlock wrapping the header of the scalar loop.
Definition VPlan.h:5081
LLVM Value Representation.
Definition Value.h:75
constexpr bool isScalable() const
Returns whether the quantity is scaled by a runtime quantity (vscale).
Definition TypeSize.h:169
constexpr ScalarTy getKnownMinValue() const
Returns the minimum value this quantity can represent.
Definition TypeSize.h:166
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
Definition iterator.h:80
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
This namespace contains an enum with a value for every intrinsic/builtin function known by LLVM.
This is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:577
bool isVectorizedTy(Type *Ty)
Returns true if Ty is a vector type or a struct of vector types where all vector types share the same...
bool canConstantBeExtended(const APInt *C, Type *NarrowType, TTI::PartialReductionExtendKind ExtKind)
Check if a constant CI can be safely treated as having been extended from a narrower type with the gi...
Definition VPlan.cpp:1821
@ Other
Any other memory.
Definition ModRef.h:68
#define N
iterator end()
const ElementCount Start
ElementCount End
iterator begin()
bool isEmpty() const
VFRange(const ElementCount &Start, const ElementCount &End)
LLVMContext & LLVMCtx
const VFSelectionContext & Config
uint64_t getCostDivisor(std::optional< VPExecutionFrequency > Freq) const
Definition VPlan.cpp:1934
LoopVectorizationCostModel & CM
TargetTransformInfo::OperandValueInfo getOperandInfo(VPValue *V) const
Returns the OperandInfo for V, if it is a live-in.
Definition VPlan.cpp:1832
VPCostContext(const TargetLibraryInfo &TLI, const VPlan &Plan, LoopVectorizationCostModel &CM, VFSelectionContext &Config, bool ReusePrintingSlotTracker=false)
static bool isFreeScalarIntrinsic(Intrinsic::ID ID)
Returns true if ID is a pseudo intrinsic that is dropped via scalarization rather than widened.
Definition VPlan.cpp:1925
bool skipCostComputation(Instruction *UI, bool IsVector) const
Return true if the cost for UI shouldn't be computed, e.g.
InstructionCost getLegacyCost(Instruction *UI, ElementCount VF) const
Return the cost for UI with VF using the legacy cost model as fallback until computing the cost of al...
bool isMaskRequired(Instruction *I) const
Forwards to LoopVectorizationCostModel::isMaskRequired.
void invalidateWideningDecision(Instruction *I, ElementCount VF)
Mark the widening decision for I at VF as invalidated since a VPlan transform replaced the original r...
PredicatedScalarEvolution & PSE
bool willBeScalarized(Instruction *I, ElementCount VF) const
Returns true if I is known to be scalarized at VF.
static bool executesAtMostOnce(const VPlan &Plan, ElementCount VF)
Returns true if the vector loop body of Plan is known to execute at most once at VF,...
std::optional< unsigned > NumPredStores
Number of predicated stores in the VPlan, computed on demand.
InstructionCost getScalarizationOverhead(Type *ResultTy, ArrayRef< const VPValue * > Operands, ElementCount VF, TTI::VectorInstrContext VIC=TTI::VectorInstrContext::None, bool AlwaysIncludeReplicatingR=false)
Estimate the overhead of scalarizing a recipe with result type ResultTy and Operands with VF.
Definition VPlan.cpp:1849
TargetTransformInfo::TargetCostKind CostKind
VPSlotTracker * getSlotTracker()
Return a VPSlotTracker to re-use for printing, lazily constructing it on first use.
Definition VPlan.cpp:1840
const TargetLibraryInfo & TLI
const TargetTransformInfo & TTI
SmallPtrSet< Instruction *, 8 > SkipCostComputation
bool useEmulatedMaskMemRefHack(const VPReplicateRecipe *R, ElementCount VF)
Returns true if an artificially high cost for emulated masked memrefs should be used.
Definition VPlan.cpp:1887
const VectorizeOptions & Opts
BasicBlock * PrevBB
The previous IR BasicBlock created or used.
BasicBlock * ExitBB
The last IR BasicBlock in the output IR.
SmallDenseMap< const VPBasicBlock *, BasicBlock * > VPBB2IRBB
A mapping of each VPBasicBlock to the corresponding BasicBlock.
DomTreeUpdater DTU
Updater for the DominatorTree.
DenseMap< const VPValue *, SmallVector< Value *, 4 > > VPV2Scalars
DenseMap< const VPValue *, Value * > VPV2Vector
LoopInfo * LI
Hold a pointer to LoopInfo to register new basic blocks in the loop.
void fixupHeaderPhis()
Add the backedge (latch) incoming value to the canonical, reduction and first-order recurrence phis i...
Definition VPlan.cpp:328
struct llvm::VPTransformState::DataState Data
void set(const VPValue *Def, Value *V, const VPLane &Lane)
Set the generated scalar V for Def and the given Lane.
IRBuilderBase & Builder
Hold a reference to the IRBuilder used to generate output IR code.
bool hasScalarValue(const VPValue *Def, VPLane Lane)
Value * get(const VPValue *Def, bool NeedsSingleScalar=false)
Get the generated vector Value for a given VPValue Def if NeedsSingleScalar is false,...
Definition VPlan.cpp:267
const TargetTransformInfo * TTI
Target Transform Info.
VPTransformState(const TargetTransformInfo *TTI, ElementCount VF, LoopInfo *LI, DominatorTree *DT, AssumptionCache *AC, IRBuilderBase &Builder, VPlan *Plan, Loop *CurrentParentLoop)
Definition VPlan.cpp:232
VPlan * Plan
Pointer to the VPlan code is generated for.
void set(const VPValue *Def, Value *V, bool IsScalar=false)
Set the generated vector Value for a given VPValue, if IsScalar is false.
bool hasVectorValue(const VPValue *Def)
VPDominatorTree VPDT
VPlan-based dominator tree.
ElementCount VF
The chosen Vectorization Factor of the loop being vectorized.
AssumptionCache * AC
Hold a pointer to AssumptionCache to register new assumptions after replicating assume calls.
void setDebugLocFrom(DebugLoc DL)
Set the debug location in the builder using the debug location DL.
Definition VPlan.cpp:306
Loop * CurrentParentLoop
The parent loop object for the current scope, or nullptr.