LLVM 22.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 InnerLoopVectorizer;
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.
47Value *getRuntimeVF(IRBuilderBase &B, Type *Ty, ElementCount VF);
48
49/// Return a value for Step multiplied by VF.
50Value *createStepForVF(IRBuilderBase &B, Type *Ty, ElementCount VF,
51 int64_t Step);
52
53/// A helper function that returns how much we should divide the cost of a
54/// predicated block by. Typically this is the reciprocal of the block
55/// probability, i.e. if we return X we are assuming the predicated block will
56/// execute once for every X iterations of the loop header so the block should
57/// only contribute 1/X of its cost to the total cost calculation, but when
58/// optimizing for code size it will just be 1 as code size costs don't depend
59/// on execution probabilities.
60///
61/// TODO: We should use actual block probability here, if available. Currently,
62/// we always assume predicated blocks have a 50% chance of executing.
63inline unsigned
65 return CostKind == TTI::TCK_CodeSize ? 1 : 2;
66}
67
68/// A range of powers-of-2 vectorization factors with fixed start and
69/// adjustable end. The range includes start and excludes end, e.g.,:
70/// [1, 16) = {1, 2, 4, 8}
71struct VFRange {
72 // A power of 2.
74
75 // A power of 2. If End <= Start range is empty.
77
78 bool isEmpty() const {
80 }
81
83 : Start(Start), End(End) {
85 "Both Start and End should have the same scalable flag");
87 "Expected Start to be a power of 2");
89 "Expected End to be a power of 2");
90 }
91
92 /// Iterator to iterate over vectorization factors in a VFRange.
94 : public iterator_facade_base<iterator, std::forward_iterator_tag,
95 ElementCount> {
96 ElementCount VF;
97
98 public:
99 iterator(ElementCount VF) : VF(VF) {}
100
101 bool operator==(const iterator &Other) const { return VF == Other.VF; }
102
103 ElementCount operator*() const { return VF; }
104
106 VF *= 2;
107 return *this;
108 }
109 };
110
114 return iterator(End);
115 }
116};
117
118/// In what follows, the term "input IR" refers to code that is fed into the
119/// vectorizer whereas the term "output IR" refers to code that is generated by
120/// the vectorizer.
121
122/// VPLane provides a way to access lanes in both fixed width and scalable
123/// vectors, where for the latter the lane index sometimes needs calculating
124/// as a runtime expression.
125class VPLane {
126public:
127 /// Kind describes how to interpret Lane.
128 enum class Kind : uint8_t {
129 /// For First, Lane is the index into the first N elements of a
130 /// fixed-vector <N x <ElTy>> or a scalable vector <vscale x N x <ElTy>>.
131 First,
132 /// For ScalableLast, Lane is the offset from the start of the last
133 /// N-element subvector in a scalable vector <vscale x N x <ElTy>>. For
134 /// example, a Lane of 0 corresponds to lane `(vscale - 1) * N`, a Lane of
135 /// 1 corresponds to `((vscale - 1) * N) + 1`, etc.
137 };
138
139private:
140 /// in [0..VF)
141 unsigned Lane;
142
143 /// Indicates how the Lane should be interpreted, as described above.
144 Kind LaneKind = Kind::First;
145
146public:
147 VPLane(unsigned Lane) : Lane(Lane) {}
148 VPLane(unsigned Lane, Kind LaneKind) : Lane(Lane), LaneKind(LaneKind) {}
149
151
152 static VPLane getLaneFromEnd(const ElementCount &VF, unsigned Offset) {
153 assert(Offset > 0 && Offset <= VF.getKnownMinValue() &&
154 "trying to extract with invalid offset");
155 unsigned LaneOffset = VF.getKnownMinValue() - Offset;
156 Kind LaneKind;
157 if (VF.isScalable())
158 // In this case 'LaneOffset' refers to the offset from the start of the
159 // last subvector with VF.getKnownMinValue() elements.
161 else
162 LaneKind = VPLane::Kind::First;
163 return VPLane(LaneOffset, LaneKind);
164 }
165
167 return getLaneFromEnd(VF, 1);
168 }
169
170 /// Returns a compile-time known value for the lane index and asserts if the
171 /// lane can only be calculated at runtime.
172 unsigned getKnownLane() const {
173 assert(LaneKind == Kind::First &&
174 "can only get known lane from the beginning");
175 return Lane;
176 }
177
178 /// Returns an expression describing the lane index that can be used at
179 /// runtime.
180 Value *getAsRuntimeExpr(IRBuilderBase &Builder, const ElementCount &VF) const;
181
182 /// Returns the Kind of lane offset.
183 Kind getKind() const { return LaneKind; }
184
185 /// Returns true if this is the first lane of the whole vector.
186 bool isFirstLane() const { return Lane == 0 && LaneKind == Kind::First; }
187
188 /// Maps the lane to a cache index based on \p VF.
189 unsigned mapToCacheIndex(const ElementCount &VF) const {
190 switch (LaneKind) {
192 assert(VF.isScalable() && Lane < VF.getKnownMinValue() &&
193 "ScalableLast can only be used with scalable VFs");
194 return VF.getKnownMinValue() + Lane;
195 default:
196 assert(Lane < VF.getKnownMinValue() &&
197 "Cannot extract lane larger than VF");
198 return Lane;
199 }
200 }
201};
202
203/// VPTransformState holds information passed down when "executing" a VPlan,
204/// needed for generating the output IR.
209 Type *CanonicalIVTy);
210 /// Target Transform Info.
212
213 /// The chosen Vectorization Factor of the loop being vectorized.
215
216 /// Hold the index to generate specific scalar instructions. Null indicates
217 /// that all instances are to be generated, using either scalar or vector
218 /// instructions.
219 std::optional<VPLane> Lane;
220
221 struct DataState {
222 // Each value from the original loop, when vectorized, is represented by a
223 // vector value in the map.
225
228
229 /// Get the generated vector Value for a given VPValue \p Def if \p IsScalar
230 /// is false, otherwise return the generated scalar. \See set.
231 Value *get(const VPValue *Def, bool IsScalar = false);
232
233 /// Get the generated Value for a given VPValue and given Part and Lane.
234 Value *get(const VPValue *Def, const VPLane &Lane);
235
236 bool hasVectorValue(const VPValue *Def) {
237 return Data.VPV2Vector.contains(Def);
238 }
239
240 bool hasScalarValue(const VPValue *Def, VPLane Lane) {
241 auto I = Data.VPV2Scalars.find(Def);
242 if (I == Data.VPV2Scalars.end())
243 return false;
244 unsigned CacheIdx = Lane.mapToCacheIndex(VF);
245 return CacheIdx < I->second.size() && I->second[CacheIdx];
246 }
247
248 /// Set the generated vector Value for a given VPValue, if \p
249 /// IsScalar is false. If \p IsScalar is true, set the scalar in lane 0.
250 void set(const VPValue *Def, Value *V, bool IsScalar = false) {
251 if (IsScalar) {
252 set(Def, V, VPLane(0));
253 return;
254 }
255 assert((VF.isScalar() || isVectorizedTy(V->getType())) &&
256 "scalar values must be stored as (0, 0)");
257 Data.VPV2Vector[Def] = V;
258 }
259
260 /// Reset an existing vector value for \p Def and a given \p Part.
261 void reset(const VPValue *Def, Value *V) {
262 assert(Data.VPV2Vector.contains(Def) && "need to overwrite existing value");
263 Data.VPV2Vector[Def] = V;
264 }
265
266 /// Set the generated scalar \p V for \p Def and the given \p Lane.
267 void set(const VPValue *Def, Value *V, const VPLane &Lane) {
268 auto &Scalars = Data.VPV2Scalars[Def];
269 unsigned CacheIdx = Lane.mapToCacheIndex(VF);
270 if (Scalars.size() <= CacheIdx)
271 Scalars.resize(CacheIdx + 1);
272 assert(!Scalars[CacheIdx] && "should overwrite existing value");
273 Scalars[CacheIdx] = V;
274 }
275
276 /// Reset an existing scalar value for \p Def and a given \p Lane.
277 void reset(const VPValue *Def, Value *V, const VPLane &Lane) {
278 auto Iter = Data.VPV2Scalars.find(Def);
279 assert(Iter != Data.VPV2Scalars.end() &&
280 "need to overwrite existing value");
281 unsigned CacheIdx = Lane.mapToCacheIndex(VF);
282 assert(CacheIdx < Iter->second.size() &&
283 "need to overwrite existing value");
284 Iter->second[CacheIdx] = V;
285 }
286
287 /// Set the debug location in the builder using the debug location \p DL.
289
290 /// Insert the scalar value of \p Def at \p Lane into \p Lane of \p WideValue
291 /// and return the resulting value.
292 Value *packScalarIntoVectorizedValue(const VPValue *Def, Value *WideValue,
293 const VPLane &Lane);
294
295 /// Hold state information used when constructing the CFG of the output IR,
296 /// traversing the VPBasicBlocks and generating corresponding IR BasicBlocks.
297 struct CFGState {
298 /// The previous VPBasicBlock visited. Initially set to null.
300
301 /// The previous IR BasicBlock created or used. Initially set to the new
302 /// header BasicBlock.
303 BasicBlock *PrevBB = nullptr;
304
305 /// The last IR BasicBlock in the output IR. Set to the exit block of the
306 /// vector loop.
307 BasicBlock *ExitBB = nullptr;
308
309 /// A mapping of each VPBasicBlock to the corresponding BasicBlock. In case
310 /// of replication, maps the BasicBlock of the last replica created.
312
313 /// Updater for the DominatorTree.
315
317 : DTU(DT, DomTreeUpdater::UpdateStrategy::Lazy) {}
319
320 /// Hold a pointer to LoopInfo to register new basic blocks in the loop.
322
323 /// Hold a pointer to AssumptionCache to register new assumptions after
324 /// replicating assume calls.
326
327 /// Hold a reference to the IRBuilder used to generate output IR code.
329
330 /// Pointer to the VPlan code is generated for.
332
333 /// The parent loop object for the current scope, or nullptr.
335
336 /// VPlan-based type analysis.
338
339 /// VPlan-based dominator tree.
341};
342
343/// Struct to hold various analysis needed for cost computations.
352
354 const VPlan &Plan, LoopVectorizationCostModel &CM,
356 : TTI(TTI), TLI(TLI), Types(Plan), LLVMCtx(Plan.getContext()), CM(CM),
358
359 /// Return the cost for \p UI with \p VF using the legacy cost model as
360 /// fallback until computing the cost of all recipes migrates to VPlan.
362
363 /// Return true if the cost for \p UI shouldn't be computed, e.g. because it
364 /// has already been pre-computed.
365 bool skipCostComputation(Instruction *UI, bool IsVector) const;
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
376/// This class can be used to assign names to VPValues. For VPValues without
377/// underlying value, assign consecutive numbers and use those as names (wrapped
378/// in vp<>). Otherwise, use the name from the underlying value (wrapped in
379/// ir<>), appending a .V version number if there are multiple uses of the same
380/// name. Allows querying names for VPValues for printing, similar to the
381/// ModuleSlotTracker for IR values.
383 /// Keep track of versioned names assigned to VPValues with underlying IR
384 /// values.
386 /// Keep track of the next number to use to version the base name.
387 StringMap<unsigned> BaseName2Version;
388
389 /// Number to assign to the next VPValue without underlying value.
390 unsigned NextSlot = 0;
391
392 /// Lazily created ModuleSlotTracker, used only when unnamed IR instructions
393 /// require slot tracking.
394 std::unique_ptr<ModuleSlotTracker> MST;
395
396 void assignName(const VPValue *V);
397 void assignNames(const VPlan &Plan);
398 void assignNames(const VPBasicBlock *VPBB);
399 std::string getName(const Value *V);
400
401public:
402 VPSlotTracker(const VPlan *Plan = nullptr) {
403 if (Plan)
404 assignNames(*Plan);
405 }
406
407 /// Returns the name assigned to \p V, if there is one, otherwise try to
408 /// construct one from the underlying value, if there's one; else return
409 /// <badref>.
410 std::string getOrCreateName(const VPValue *V) const;
411};
412
413#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
414/// VPlanPrinter prints a given VPlan to a given output stream. The printing is
415/// indented and follows the dot format.
417 raw_ostream &OS;
418 const VPlan &Plan;
419 unsigned Depth = 0;
420 unsigned TabWidth = 2;
421 std::string Indent;
422 unsigned BID = 0;
424
426
427 /// Handle indentation.
428 void bumpIndent(int b) { Indent = std::string((Depth += b) * TabWidth, ' '); }
429
430 /// Print a given \p Block of the Plan.
431 void dumpBlock(const VPBlockBase *Block);
432
433 /// Print the information related to the CFG edges going out of a given
434 /// \p Block, followed by printing the successor blocks themselves.
435 void dumpEdges(const VPBlockBase *Block);
436
437 /// Print a given \p BasicBlock, including its VPRecipes, followed by printing
438 /// its successor blocks.
439 void dumpBasicBlock(const VPBasicBlock *BasicBlock);
440
441 /// Print a given \p Region of the Plan.
442 void dumpRegion(const VPRegionBlock *Region);
443
444 unsigned getOrCreateBID(const VPBlockBase *Block) {
445 return BlockID.count(Block) ? BlockID[Block] : BlockID[Block] = BID++;
446 }
447
448 Twine getOrCreateName(const VPBlockBase *Block);
449
450 Twine getUID(const VPBlockBase *Block);
451
452 /// Print the information related to a CFG edge between two VPBlockBases.
453 void drawEdge(const VPBlockBase *From, const VPBlockBase *To, bool Hidden,
454 const Twine &Label);
455
456public:
458 : OS(O), Plan(P), SlotTracker(&P) {}
459
460 LLVM_DUMP_METHOD void dump();
461};
462#endif
463
464} // end namespace llvm
465
466#endif // LLVM_TRANSFORMS_VECTORIZE_VPLAN_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
BlockVerifier::State From
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
RelocType Type
Definition: COFFYAML.cpp:410
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
Definition: Compiler.h:638
static cl::opt< OutputCostKind > CostKind("cost-kind", cl::desc("Target cost kind"), cl::init(OutputCostKind::RecipThroughput), cl::values(clEnumValN(OutputCostKind::RecipThroughput, "throughput", "Reciprocal throughput"), clEnumValN(OutputCostKind::Latency, "latency", "Instruction latency"), clEnumValN(OutputCostKind::CodeSize, "code-size", "Code size"), clEnumValN(OutputCostKind::SizeAndLatency, "size-latency", "Code size and latency"), clEnumValN(OutputCostKind::All, "all", "Print all cost kinds")))
This file defines the DenseMap class.
This file defines an InstructionCost class that is used when calculating the cost of an instruction,...
#define I(x, y, z)
Definition: MD5.cpp:58
#define P(N)
raw_pwrite_stream & OS
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.
A cache of @llvm.assume calls within a function.
LLVM Basic Block Representation.
Definition: BasicBlock.h:62
A debug info location.
Definition: DebugLoc.h:124
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
Definition: DenseMap.h:173
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Definition: Dominators.h:165
constexpr bool isScalar() const
Exactly one element.
Definition: TypeSize.h:323
Common base class shared among various IRBuilders.
Definition: IRBuilder.h:114
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
This class provides computation of slot numbers for LLVM Assembly writing.
Definition: AsmWriter.cpp:757
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
Definition: SmallPtrSet.h:541
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.
TargetCostKind
The kind of cost model.
@ TCK_CodeSize
Instruction code size.
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:45
Iterator to iterate over vectorization factors in a VFRange.
Definition: VPlanHelpers.h:95
ElementCount operator*() const
Definition: VPlanHelpers.h:103
iterator(ElementCount VF)
Definition: VPlanHelpers.h:99
bool operator==(const iterator &Other) const
Definition: VPlanHelpers.h:101
VPBasicBlock serves as the leaf of the Hierarchical Control-Flow Graph.
Definition: VPlan.h:3639
VPBlockBase is the building block of the Hierarchical Control-Flow Graph.
Definition: VPlan.h:81
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 ...
Definition: VPlanHelpers.h:125
static VPLane getLastLaneForVF(const ElementCount &VF)
Definition: VPlanHelpers.h:166
Value * getAsRuntimeExpr(IRBuilderBase &Builder, const ElementCount &VF) const
Returns an expression describing the lane index that can be used at runtime.
Definition: VPlan.cpp:75
VPLane(unsigned Lane, Kind LaneKind)
Definition: VPlanHelpers.h:148
Kind getKind() const
Returns the Kind of lane offset.
Definition: VPlanHelpers.h:183
static VPLane getLaneFromEnd(const ElementCount &VF, unsigned Offset)
Definition: VPlanHelpers.h:152
bool isFirstLane() const
Returns true if this is the first lane of the whole vector.
Definition: VPlanHelpers.h:186
VPLane(unsigned Lane)
Definition: VPlanHelpers.h:147
unsigned getKnownLane() const
Returns a compile-time known value for the lane index and asserts if the lane can only be calculated ...
Definition: VPlanHelpers.h:172
static VPLane getFirstLane()
Definition: VPlanHelpers.h:150
Kind
Kind describes how to interpret Lane.
Definition: VPlanHelpers.h:128
@ 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.
Definition: VPlanHelpers.h:189
VPRegionBlock represents a collection of VPBasicBlocks and VPRegionBlocks which form a Single-Entry-S...
Definition: VPlan.h:3827
This class can be used to assign names to VPValues.
Definition: VPlanHelpers.h:382
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:1539
VPSlotTracker(const VPlan *Plan=nullptr)
Definition: VPlanHelpers.h:402
An analysis for type-inference for VPValues.
Definition: VPlanAnalysis.h:43
VPlanPrinter prints a given VPlan to a given output stream.
Definition: VPlanHelpers.h:416
VPlanPrinter(raw_ostream &O, const VPlan &P)
Definition: VPlanHelpers.h:457
LLVM_DUMP_METHOD void dump()
Definition: VPlan.cpp:1274
VPlan models a candidate for vectorization, encoding various decisions take to produce efficient outp...
Definition: VPlan.h:3930
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:172
constexpr ScalarTy getKnownMinValue() const
Returns the minimum value this quantity can represent.
Definition: TypeSize.h:169
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
@ BasicBlock
Various leaf nodes.
Definition: ISDOpcodes.h:81
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Offset
Definition: DWP.cpp:477
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:288
@ Other
Any other memory.
Value * createStepForVF(IRBuilderBase &B, Type *Ty, ElementCount VF, int64_t Step)
Return a value for Step multiplied by VF.
unsigned getPredBlockCostDivisor(TargetTransformInfo::TargetCostKind CostKind)
A helper function that returns how much we should divide the cost of a predicated block by.
Definition: VPlanHelpers.h:64
A range of powers-of-2 vectorization factors with fixed start and adjustable end.
Definition: VPlanHelpers.h:71
iterator end()
Definition: VPlanHelpers.h:112
const ElementCount Start
Definition: VPlanHelpers.h:73
ElementCount End
Definition: VPlanHelpers.h:76
iterator begin()
Definition: VPlanHelpers.h:111
bool isEmpty() const
Definition: VPlanHelpers.h:78
VFRange(const ElementCount &Start, const ElementCount &End)
Definition: VPlanHelpers.h:82
Struct to hold various analysis needed for cost computations.
Definition: VPlanHelpers.h:344
LLVMContext & LLVMCtx
Definition: VPlanHelpers.h:348
LoopVectorizationCostModel & CM
Definition: VPlanHelpers.h:349
TargetTransformInfo::OperandValueInfo getOperandInfo(VPValue *V) const
Returns the OperandInfo for V, if it is a live-in.
Definition: VPlan.cpp:1630
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...
TargetTransformInfo::TargetCostKind CostKind
Definition: VPlanHelpers.h:351
VPTypeAnalysis Types
Definition: VPlanHelpers.h:347
const TargetLibraryInfo & TLI
Definition: VPlanHelpers.h:346
const TargetTransformInfo & TTI
Definition: VPlanHelpers.h:345
VPCostContext(const TargetTransformInfo &TTI, const TargetLibraryInfo &TLI, const VPlan &Plan, LoopVectorizationCostModel &CM, TargetTransformInfo::TargetCostKind CostKind)
Definition: VPlanHelpers.h:353
SmallPtrSet< Instruction *, 8 > SkipCostComputation
Definition: VPlanHelpers.h:350
Hold state information used when constructing the CFG of the output IR, traversing the VPBasicBlocks ...
Definition: VPlanHelpers.h:297
BasicBlock * PrevBB
The previous IR BasicBlock created or used.
Definition: VPlanHelpers.h:303
VPBasicBlock * PrevVPBB
The previous VPBasicBlock visited. Initially set to null.
Definition: VPlanHelpers.h:299
BasicBlock * ExitBB
The last IR BasicBlock in the output IR.
Definition: VPlanHelpers.h:307
SmallDenseMap< const VPBasicBlock *, BasicBlock * > VPBB2IRBB
A mapping of each VPBasicBlock to the corresponding BasicBlock.
Definition: VPlanHelpers.h:311
DomTreeUpdater DTU
Updater for the DominatorTree.
Definition: VPlanHelpers.h:314
DenseMap< const VPValue *, SmallVector< Value *, 4 > > VPV2Scalars
Definition: VPlanHelpers.h:226
DenseMap< const VPValue *, Value * > VPV2Vector
Definition: VPlanHelpers.h:224
VPTransformState holds information passed down when "executing" a VPlan, needed for generating the ou...
Definition: VPlanHelpers.h:205
LoopInfo * LI
Hold a pointer to LoopInfo to register new basic blocks in the loop.
Definition: VPlanHelpers.h:321
void reset(const VPValue *Def, Value *V)
Reset an existing vector value for Def and a given Part.
Definition: VPlanHelpers.h:261
VPTypeAnalysis TypeAnalysis
VPlan-based type analysis.
Definition: VPlanHelpers.h:337
struct llvm::VPTransformState::DataState Data
struct llvm::VPTransformState::CFGState CFG
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:283
std::optional< VPLane > Lane
Hold the index to generate specific scalar instructions.
Definition: VPlanHelpers.h:219
void set(const VPValue *Def, Value *V, const VPLane &Lane)
Set the generated scalar V for Def and the given Lane.
Definition: VPlanHelpers.h:267
IRBuilderBase & Builder
Hold a reference to the IRBuilder used to generate output IR code.
Definition: VPlanHelpers.h:328
bool hasScalarValue(const VPValue *Def, VPLane Lane)
Definition: VPlanHelpers.h:240
const TargetTransformInfo * TTI
Target Transform Info.
Definition: VPlanHelpers.h:211
VPlan * Plan
Pointer to the VPlan code is generated for.
Definition: VPlanHelpers.h:331
void set(const VPValue *Def, Value *V, bool IsScalar=false)
Set the generated vector Value for a given VPValue, if IsScalar is false.
Definition: VPlanHelpers.h:250
bool hasVectorValue(const VPValue *Def)
Definition: VPlanHelpers.h:236
VPDominatorTree VPDT
VPlan-based dominator tree.
Definition: VPlanHelpers.h:340
ElementCount VF
The chosen Vectorization Factor of the loop being vectorized.
Definition: VPlanHelpers.h:214
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:393
AssumptionCache * AC
Hold a pointer to AssumptionCache to register new assumptions after replicating assume calls.
Definition: VPlanHelpers.h:325
void setDebugLocFrom(DebugLoc DL)
Set the debug location in the builder using the debug location DL.
Definition: VPlan.cpp:371
Loop * CurrentParentLoop
The parent loop object for the current scope, or nullptr.
Definition: VPlanHelpers.h:334
void reset(const VPValue *Def, Value *V, const VPLane &Lane)
Reset an existing scalar value for Def and a given Lane.
Definition: VPlanHelpers.h:277