LLVM 23.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;
35class IRBuilderBase;
36class LoopInfo;
37class SCEV;
38class Type;
39class VPBasicBlock;
40class VPRegionBlock;
41class VPlan;
42class Value;
43
44/// Returns a calculation for the total number of elements for a given \p VF.
45/// For fixed width vectors this value is a constant, whereas for scalable
46/// vectors it is an expression determined at runtime.
48
49/// Compute the transformed value of Index at offset StartValue using step
50/// StepValue.
51/// For integer induction, returns StartValue + Index * StepValue.
52/// For pointer induction, returns StartValue[Index * StepValue].
54 Value *Step,
56 const BinaryOperator *InductionBinOp);
57
58/// A range of powers-of-2 vectorization factors with fixed start and
59/// adjustable end. The range includes start and excludes end, e.g.,:
60/// [1, 16) = {1, 2, 4, 8}
61struct VFRange {
62 // A power of 2.
64
65 // A power of 2. If End <= Start range is empty.
67
68 bool isEmpty() const {
69 return End.getKnownMinValue() <= Start.getKnownMinValue();
70 }
71
73 : Start(Start), End(End) {
74 assert(Start.isScalable() == End.isScalable() &&
75 "Both Start and End should have the same scalable flag");
76 assert(isPowerOf2_32(Start.getKnownMinValue()) &&
77 "Expected Start to be a power of 2");
78 assert(isPowerOf2_32(End.getKnownMinValue()) &&
79 "Expected End to be a power of 2");
80 }
81
82 /// Iterator to iterate over vectorization factors in a VFRange.
84 : public iterator_facade_base<iterator, std::forward_iterator_tag,
85 ElementCount> {
86 ElementCount VF;
87
88 public:
89 iterator(ElementCount VF) : VF(VF) {}
90
91 bool operator==(const iterator &Other) const { return VF == Other.VF; }
92
93 ElementCount operator*() const { return VF; }
94
96 VF *= 2;
97 return *this;
98 }
99 };
100
103 assert(isPowerOf2_32(End.getKnownMinValue()));
104 return iterator(End);
105 }
106};
107
108/// In what follows, the term "input IR" refers to code that is fed into the
109/// vectorizer whereas the term "output IR" refers to code that is generated by
110/// the vectorizer.
111
112/// VPLane provides a way to access lanes in both fixed width and scalable
113/// vectors, where for the latter the lane index sometimes needs calculating
114/// as a runtime expression.
115class VPLane {
116public:
117 /// Kind describes how to interpret Lane.
118 enum class Kind : uint8_t {
119 /// For First, Lane is the index into the first N elements of a
120 /// fixed-vector <N x <ElTy>> or a scalable vector <vscale x N x <ElTy>>.
122 /// For ScalableLast, Lane is the offset from the start of the last
123 /// N-element subvector in a scalable vector <vscale x N x <ElTy>>. For
124 /// example, a Lane of 0 corresponds to lane `(vscale - 1) * N`, a Lane of
125 /// 1 corresponds to `((vscale - 1) * N) + 1`, etc.
127 };
128
129private:
130 /// in [0..VF)
131 unsigned Lane;
132
133 /// Indicates how the Lane should be interpreted, as described above.
134 Kind LaneKind = Kind::First;
135
136public:
137 VPLane(unsigned Lane) : Lane(Lane) {}
138 VPLane(unsigned Lane, Kind LaneKind) : Lane(Lane), LaneKind(LaneKind) {}
139
141
142 static VPLane getLaneFromEnd(const ElementCount &VF, unsigned Offset) {
143 assert(Offset > 0 && Offset <= VF.getKnownMinValue() &&
144 "trying to extract with invalid offset");
145 unsigned LaneOffset = VF.getKnownMinValue() - Offset;
146 Kind LaneKind;
147 if (VF.isScalable())
148 // In this case 'LaneOffset' refers to the offset from the start of the
149 // last subvector with VF.getKnownMinValue() elements.
151 else
152 LaneKind = VPLane::Kind::First;
153 return VPLane(LaneOffset, LaneKind);
154 }
155
157 return getLaneFromEnd(VF, 1);
158 }
159
160 /// Returns a compile-time known value for the lane index and asserts if the
161 /// lane can only be calculated at runtime.
162 unsigned getKnownLane() const {
163 assert(LaneKind == Kind::First &&
164 "can only get known lane from the beginning");
165 return Lane;
166 }
167
168 /// Returns an expression describing the lane index that can be used at
169 /// runtime.
170 Value *getAsRuntimeExpr(IRBuilderBase &Builder, const ElementCount &VF) const;
171
172 /// Returns the Kind of lane offset.
173 Kind getKind() const { return LaneKind; }
174
175 /// Returns true if this is the first lane of the whole vector.
176 bool isFirstLane() const { return Lane == 0 && LaneKind == Kind::First; }
177
178 /// Maps the lane to a cache index based on \p VF.
179 unsigned mapToCacheIndex(const ElementCount &VF) const {
180 switch (LaneKind) {
182 assert(VF.isScalable() && Lane < VF.getKnownMinValue() &&
183 "ScalableLast can only be used with scalable VFs");
184 return VF.getKnownMinValue() + Lane;
185 default:
186 assert(Lane < VF.getKnownMinValue() &&
187 "Cannot extract lane larger than VF");
188 return Lane;
189 }
190 }
191};
192
193/// VPTransformState holds information passed down when "executing" a VPlan,
194/// needed for generating the output IR.
199 Type *CanonicalIVTy);
200 /// Target Transform Info.
202
203 /// The chosen Vectorization Factor of the loop being vectorized.
205
206 /// Hold the index to generate specific scalar instructions. Null indicates
207 /// that all instances are to be generated, using either scalar or vector
208 /// instructions.
209 std::optional<VPLane> Lane;
210
211 struct DataState {
212 // Each value from the original loop, when vectorized, is represented by a
213 // vector value in the map.
215
218
219 /// Get the generated vector Value for a given VPValue \p Def if \p IsScalar
220 /// is false, otherwise return the generated scalar. \See set.
221 Value *get(const VPValue *Def, bool IsScalar = false);
222
223 /// Get the generated Value for a given VPValue and given Part and Lane.
224 Value *get(const VPValue *Def, const VPLane &Lane);
225
226 bool hasVectorValue(const VPValue *Def) {
227 return Data.VPV2Vector.contains(Def);
228 }
229
230 bool hasScalarValue(const VPValue *Def, VPLane Lane) {
231 auto I = Data.VPV2Scalars.find(Def);
232 if (I == Data.VPV2Scalars.end())
233 return false;
234 unsigned CacheIdx = Lane.mapToCacheIndex(VF);
235 return CacheIdx < I->second.size() && I->second[CacheIdx];
236 }
237
238 /// Set the generated vector Value for a given VPValue, if \p
239 /// IsScalar is false. If \p IsScalar is true, set the scalar in lane 0.
240 void set(const VPValue *Def, Value *V, bool IsScalar = false) {
241 if (IsScalar) {
242 set(Def, V, VPLane(0));
243 return;
244 }
245 assert((VF.isScalar() || isVectorizedTy(V->getType())) &&
246 "scalar values must be stored as (0, 0)");
247 Data.VPV2Vector[Def] = V;
248 }
249
250 /// Reset an existing vector value for \p Def and a given \p Part.
251 void reset(const VPValue *Def, Value *V) {
252 assert(Data.VPV2Vector.contains(Def) && "need to overwrite existing value");
253 Data.VPV2Vector[Def] = V;
254 }
255
256 /// Set the generated scalar \p V for \p Def and the given \p Lane.
257 void set(const VPValue *Def, Value *V, const VPLane &Lane) {
258 auto &Scalars = Data.VPV2Scalars[Def];
259 unsigned CacheIdx = Lane.mapToCacheIndex(VF);
260 if (Scalars.size() <= CacheIdx)
261 Scalars.resize(CacheIdx + 1);
262 assert(!Scalars[CacheIdx] && "should overwrite existing value");
263 Scalars[CacheIdx] = V;
264 }
265
266 /// Reset an existing scalar value for \p Def and a given \p Lane.
267 void reset(const VPValue *Def, Value *V, const VPLane &Lane) {
268 auto Iter = Data.VPV2Scalars.find(Def);
269 assert(Iter != Data.VPV2Scalars.end() &&
270 "need to overwrite existing value");
271 unsigned CacheIdx = Lane.mapToCacheIndex(VF);
272 assert(CacheIdx < Iter->second.size() &&
273 "need to overwrite existing value");
274 Iter->second[CacheIdx] = V;
275 }
276
277 /// Set the debug location in the builder using the debug location \p DL.
279
280 /// Insert the scalar value of \p Def at \p Lane into \p Lane of \p WideValue
281 /// and return the resulting value.
282 Value *packScalarIntoVectorizedValue(const VPValue *Def, Value *WideValue,
283 const VPLane &Lane);
284
285 /// Hold state information used when constructing the CFG of the output IR,
286 /// traversing the VPBasicBlocks and generating corresponding IR BasicBlocks.
287 struct CFGState {
288 /// The previous VPBasicBlock visited. Initially set to null.
290
291 /// The previous IR BasicBlock created or used. Initially set to the new
292 /// header BasicBlock.
293 BasicBlock *PrevBB = nullptr;
294
295 /// The last IR BasicBlock in the output IR. Set to the exit block of the
296 /// vector loop.
297 BasicBlock *ExitBB = nullptr;
298
299 /// A mapping of each VPBasicBlock to the corresponding BasicBlock. In case
300 /// of replication, maps the BasicBlock of the last replica created.
302
303 /// Updater for the DominatorTree.
305
307 : DTU(DT, DomTreeUpdater::UpdateStrategy::Lazy) {}
309
310 /// Hold a pointer to LoopInfo to register new basic blocks in the loop.
312
313 /// Hold a pointer to AssumptionCache to register new assumptions after
314 /// replicating assume calls.
316
317 /// Hold a reference to the IRBuilder used to generate output IR code.
319
320 /// Pointer to the VPlan code is generated for.
322
323 /// The parent loop object for the current scope, or nullptr.
325
326 /// VPlan-based type analysis.
328
329 /// VPlan-based dominator tree.
331};
332
333/// Struct to hold various analysis needed for cost computations.
343 const Loop *L;
344
345 /// Number of predicated stores in the VPlan, computed on demand.
346 std::optional<unsigned> NumPredStores;
347
354
355 /// Return the cost for \p UI with \p VF using the legacy cost model as
356 /// fallback until computing the cost of all recipes migrates to VPlan.
358
359 /// Return true if the cost for \p UI shouldn't be computed, e.g. because it
360 /// has already been pre-computed.
361 bool skipCostComputation(Instruction *UI, bool IsVector) const;
362
363 /// \returns how much the cost of a predicated block should be divided by.
364 /// Forwards to LoopVectorizationCostModel::getPredBlockCostDivisor.
366
367 /// Returns the OperandInfo for \p V, if it is a live-in.
369
370 /// Return true if \p I is considered uniform-after-vectorization in the
371 /// legacy cost model for \p VF. Only used to check for additional VPlan
372 /// simplifications.
374
375 /// Estimate the overhead of scalarizing a recipe with result type \p ResultTy
376 /// and \p Operands with \p VF. This is a convenience wrapper for the
377 /// type-based getScalarizationOverhead API. \p VIC provides context about
378 /// whether the scalarization is for a load/store operation. If \p
379 /// AlwaysIncludeReplicatingR is true, always compute the cost of scalarizing
380 /// replicating operands.
382 Type *ResultTy, ArrayRef<const VPValue *> Operands, ElementCount VF,
384 bool AlwaysIncludeReplicatingR = false);
385
386 /// Returns true if an artificially high cost for emulated masked memrefs
387 /// should be used.
389};
390
391/// This class can be used to assign names to VPValues. For VPValues without
392/// underlying value, assign consecutive numbers and use those as names (wrapped
393/// in vp<>). Otherwise, use the name from the underlying value (wrapped in
394/// ir<>), appending a .V version number if there are multiple uses of the same
395/// name. Allows querying names for VPValues for printing, similar to the
396/// ModuleSlotTracker for IR values.
398 /// Keep track of versioned names assigned to VPValues with underlying IR
399 /// values.
401 /// Keep track of the next number to use to version the base name.
402 StringMap<unsigned> BaseName2Version;
403
404 /// Number to assign to the next VPValue without underlying value.
405 unsigned NextSlot = 0;
406
407 /// Lazily created ModuleSlotTracker, used only when unnamed IR instructions
408 /// require slot tracking.
409 std::unique_ptr<ModuleSlotTracker> MST;
410
411 /// Cached metadata kind names from the Module's LLVMContext.
413
414 /// Cached Module pointer for printing metadata.
415 const Module *M = nullptr;
416
417 void assignName(const VPValue *V);
418 LLVM_ABI_FOR_TEST void assignNames(const VPlan &Plan);
419 void assignNames(const VPBasicBlock *VPBB);
420 std::string getName(const Value *V);
421
422public:
423 VPSlotTracker(const VPlan *Plan = nullptr) {
424 if (Plan) {
425 assignNames(*Plan);
426 if (auto *ScalarHeader = Plan->getScalarHeader())
427 M = ScalarHeader->getIRBasicBlock()->getModule();
428 }
429 }
430
431 /// Returns the name assigned to \p V, if there is one, otherwise try to
432 /// construct one from the underlying value, if there's one; else return
433 /// <badref>.
434 std::string getOrCreateName(const VPValue *V) const;
435
436 /// Returns the cached metadata kind names.
438 if (MDNames.empty() && M)
439 M->getContext().getMDKindNames(MDNames);
440 return MDNames;
441 }
442
443 /// Returns the cached Module pointer.
444 const Module *getModule() const { return M; }
445};
446
447#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
448/// VPlanPrinter prints a given VPlan to a given output stream. The printing is
449/// indented and follows the dot format.
451 raw_ostream &OS;
452 const VPlan &Plan;
453 unsigned Depth = 0;
454 unsigned TabWidth = 2;
455 std::string Indent;
456 unsigned BID = 0;
458
459 VPSlotTracker SlotTracker;
460
461 /// Handle indentation.
462 void bumpIndent(int b) { Indent = std::string((Depth += b) * TabWidth, ' '); }
463
464 /// Print a given \p Block of the Plan.
465 void dumpBlock(const VPBlockBase *Block);
466
467 /// Print the information related to the CFG edges going out of a given
468 /// \p Block, followed by printing the successor blocks themselves.
469 void dumpEdges(const VPBlockBase *Block);
470
471 /// Print a given \p BasicBlock, including its VPRecipes, followed by printing
472 /// its successor blocks.
473 void dumpBasicBlock(const VPBasicBlock *BasicBlock);
474
475 /// Print a given \p Region of the Plan.
476 void dumpRegion(const VPRegionBlock *Region);
477
478 unsigned getOrCreateBID(const VPBlockBase *Block) {
479 return BlockID.count(Block) ? BlockID[Block] : BlockID[Block] = BID++;
480 }
481
482 Twine getOrCreateName(const VPBlockBase *Block);
483
484 Twine getUID(const VPBlockBase *Block);
485
486 /// Print the information related to a CFG edge between two VPBlockBases.
487 void drawEdge(const VPBlockBase *From, const VPBlockBase *To, bool Hidden,
488 const Twine &Label);
489
490public:
492 : OS(O), Plan(P), SlotTracker(&P) {}
493
494 LLVM_DUMP_METHOD void dump();
495};
496#endif
497
498/// Check if a constant \p CI can be safely treated as having been extended
499/// from a narrower type with the given extension kind.
500bool canConstantBeExtended(const APInt *C, Type *NarrowType,
502} // end namespace llvm
503
504#endif // LLVM_TRANSFORMS_VECTORIZE_VPLAN_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
Definition Compiler.h:661
#define LLVM_ABI_FOR_TEST
Definition Compiler.h:218
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)
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.
ArrayRef - 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
A debug info location.
Definition DebugLoc.h:123
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Definition Dominators.h:159
Common base class shared among various IRBuilders.
Definition IRBuilder.h:114
InductionKind
This enum represents the kinds of inductions that we support.
InnerLoopVectorizer vectorizes loops which contain only one basic block to a specified vectorization ...
This is an important class for using LLVM in a threaded context.
Definition LLVMContext.h:68
LoopVectorizationCostModel - estimates the expected speedups due to vectorization.
Represents a single loop in the control flow graph.
Definition LoopInfo.h:40
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:67
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.
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:133
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.
VectorInstrContext
Represents a hint about the context in which an insert/extract is used.
@ None
The insert/extract is not used with a load/store.
TargetCostKind
The kind of cost model.
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
VPBasicBlock serves as the leaf of the Hierarchical Control-Flow Graph.
Definition VPlan.h:4253
VPBlockBase is the building block of the Hierarchical Control-Flow Graph.
Definition VPlan.h:98
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:87
VPLane(unsigned Lane, Kind LaneKind)
Kind getKind() const
Returns the Kind of lane offset.
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)
unsigned getKnownLane() const
Returns a compile-time known value for the lane index and asserts if the lane can only be calculated ...
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:4441
VPReplicateRecipe replicates a given instruction producing multiple scalar copies of the original sca...
Definition VPlan.h:3217
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:1569
const Module * getModule() const
Returns the cached Module pointer.
VPSlotTracker(const VPlan *Plan=nullptr)
An analysis for type-inference for VPValues.
This is the base class of the VPlan Def/Use graph, used for modeling the data flow into,...
Definition VPlanValue.h:46
VPlanPrinter(raw_ostream &O, const VPlan &P)
LLVM_DUMP_METHOD void dump()
Definition VPlan.cpp:1299
VPlan models a candidate for vectorization, encoding various decisions take to produce efficient outp...
Definition VPlan.h:4571
VPIRBasicBlock * getScalarHeader() const
Return the VPIRBasicBlock wrapping the header of the scalar loop.
Definition VPlan.h:4707
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:168
constexpr ScalarTy getKnownMinValue() const
Returns the minimum value this quantity can represent.
Definition TypeSize.h:165
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 is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:532
Value * getRuntimeVF(IRBuilderBase &B, Type *Ty, ElementCount VF)
Return the runtime value for VF.
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...
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
Definition MathExtras.h:279
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:1790
@ Other
Any other memory.
Definition ModRef.h:68
FunctionAddr VTableAddr uintptr_t uintptr_t Data
Definition InstrProf.h:221
Value * emitTransformedIndex(IRBuilderBase &B, Value *Index, Value *StartValue, Value *Step, InductionDescriptor::InductionKind InductionKind, const BinaryOperator *InductionBinOp)
Compute the transformed value of Index at offset StartValue using step StepValue.
iterator end()
const ElementCount Start
ElementCount End
iterator begin()
bool isEmpty() const
VFRange(const ElementCount &Start, const ElementCount &End)
LLVMContext & LLVMCtx
LoopVectorizationCostModel & CM
TargetTransformInfo::OperandValueInfo getOperandInfo(VPValue *V) const
Returns the OperandInfo for V, if it is a live-in.
Definition VPlan.cpp:1801
bool isLegacyUniformAfterVectorization(Instruction *I, ElementCount VF) const
Return true if I is considered uniform-after-vectorization in the legacy cost model for VF.
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...
PredicatedScalarEvolution & PSE
uint64_t getPredBlockCostDivisor(BasicBlock *BB) const
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:1808
TargetTransformInfo::TargetCostKind CostKind
VPTypeAnalysis Types
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:1846
VPCostContext(const TargetTransformInfo &TTI, const TargetLibraryInfo &TLI, const VPlan &Plan, LoopVectorizationCostModel &CM, TargetTransformInfo::TargetCostKind CostKind, PredicatedScalarEvolution &PSE, const Loop *L)
BasicBlock * PrevBB
The previous IR BasicBlock created or used.
VPBasicBlock * PrevVPBB
The previous VPBasicBlock visited. Initially set to null.
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 reset(const VPValue *Def, Value *V)
Reset an existing vector value for Def and a given Part.
VPTypeAnalysis TypeAnalysis
VPlan-based type analysis.
struct llvm::VPTransformState::DataState Data
Value * get(const VPValue *Def, bool IsScalar=false)
Get the generated vector Value for a given VPValue Def if IsScalar is false, otherwise return the gen...
Definition VPlan.cpp:279
VPTransformState(const TargetTransformInfo *TTI, ElementCount VF, LoopInfo *LI, DominatorTree *DT, AssumptionCache *AC, IRBuilderBase &Builder, VPlan *Plan, Loop *CurrentParentLoop, Type *CanonicalIVTy)
Definition VPlan.cpp:239
std::optional< VPLane > Lane
Hold the index to generate specific scalar instructions.
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)
const TargetTransformInfo * TTI
Target Transform Info.
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.
Value * packScalarIntoVectorizedValue(const VPValue *Def, Value *WideValue, const VPLane &Lane)
Insert the scalar value of Def at Lane into Lane of WideValue and return the resulting value.
Definition VPlan.cpp:361
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:339
Loop * CurrentParentLoop
The parent loop object for the current scope, or nullptr.
void reset(const VPValue *Def, Value *V, const VPLane &Lane)
Reset an existing scalar value for Def and a given Lane.