LLVM 21.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 "llvm/ADT/DenseMap.h"
24#include "llvm/IR/DebugLoc.h"
26
27namespace llvm {
28
29class BasicBlock;
30class DominatorTree;
31class InnerLoopVectorizer;
32class IRBuilderBase;
33class LoopInfo;
34class SCEV;
35class Type;
36class VPBasicBlock;
37class VPRegionBlock;
38class VPlan;
39class Value;
40class LoopVersioning;
41
42/// Returns a calculation for the total number of elements for a given \p VF.
43/// For fixed width vectors this value is a constant, whereas for scalable
44/// vectors it is an expression determined at runtime.
45Value *getRuntimeVF(IRBuilderBase &B, Type *Ty, ElementCount VF);
46
47/// Return a value for Step multiplied by VF.
48Value *createStepForVF(IRBuilderBase &B, Type *Ty, ElementCount VF,
49 int64_t Step);
50
51/// A helper function that returns the reciprocal of the block probability of
52/// predicated blocks. If we return X, we are assuming the predicated block
53/// will execute once for every X iterations of the loop header.
54///
55/// TODO: We should use actual block probability here, if available. Currently,
56/// we always assume predicated blocks have a 50% chance of executing.
57inline unsigned getReciprocalPredBlockProb() { return 2; }
58
59/// A range of powers-of-2 vectorization factors with fixed start and
60/// adjustable end. The range includes start and excludes end, e.g.,:
61/// [1, 16) = {1, 2, 4, 8}
62struct VFRange {
63 // A power of 2.
65
66 // A power of 2. If End <= Start range is empty.
68
69 bool isEmpty() const {
71 }
72
74 : Start(Start), End(End) {
76 "Both Start and End should have the same scalable flag");
78 "Expected Start to be a power of 2");
80 "Expected End to be a power of 2");
81 }
82
83 /// Iterator to iterate over vectorization factors in a VFRange.
85 : public iterator_facade_base<iterator, std::forward_iterator_tag,
86 ElementCount> {
87 ElementCount VF;
88
89 public:
90 iterator(ElementCount VF) : VF(VF) {}
91
92 bool operator==(const iterator &Other) const { return VF == Other.VF; }
93
94 ElementCount operator*() const { return VF; }
95
97 VF *= 2;
98 return *this;
99 }
100 };
101
105 return iterator(End);
106 }
107};
108
109/// In what follows, the term "input IR" refers to code that is fed into the
110/// vectorizer whereas the term "output IR" refers to code that is generated by
111/// the vectorizer.
112
113/// VPLane provides a way to access lanes in both fixed width and scalable
114/// vectors, where for the latter the lane index sometimes needs calculating
115/// as a runtime expression.
116class VPLane {
117public:
118 /// Kind describes how to interpret Lane.
119 enum class Kind : uint8_t {
120 /// For First, Lane is the index into the first N elements of a
121 /// fixed-vector <N x <ElTy>> or a scalable vector <vscale x N x <ElTy>>.
122 First,
123 /// For ScalableLast, Lane is the offset from the start of the last
124 /// N-element subvector in a scalable vector <vscale x N x <ElTy>>. For
125 /// example, a Lane of 0 corresponds to lane `(vscale - 1) * N`, a Lane of
126 /// 1 corresponds to `((vscale - 1) * N) + 1`, etc.
128 };
129
130private:
131 /// in [0..VF)
132 unsigned Lane;
133
134 /// Indicates how the Lane should be interpreted, as described above.
135 Kind LaneKind = Kind::First;
136
137public:
138 VPLane(unsigned Lane) : Lane(Lane) {}
139 VPLane(unsigned Lane, Kind LaneKind) : Lane(Lane), LaneKind(LaneKind) {}
140
142
143 static VPLane getLaneFromEnd(const ElementCount &VF, unsigned Offset) {
144 assert(Offset > 0 && Offset <= VF.getKnownMinValue() &&
145 "trying to extract with invalid offset");
146 unsigned LaneOffset = VF.getKnownMinValue() - Offset;
147 Kind LaneKind;
148 if (VF.isScalable())
149 // In this case 'LaneOffset' refers to the offset from the start of the
150 // last subvector with VF.getKnownMinValue() elements.
152 else
153 LaneKind = VPLane::Kind::First;
154 return VPLane(LaneOffset, LaneKind);
155 }
156
158 return getLaneFromEnd(VF, 1);
159 }
160
161 /// Returns a compile-time known value for the lane index and asserts if the
162 /// lane can only be calculated at runtime.
163 unsigned getKnownLane() const {
164 assert(LaneKind == Kind::First &&
165 "can only get known lane from the beginning");
166 return Lane;
167 }
168
169 /// Returns an expression describing the lane index that can be used at
170 /// runtime.
171 Value *getAsRuntimeExpr(IRBuilderBase &Builder, const ElementCount &VF) const;
172
173 /// Returns the Kind of lane offset.
174 Kind getKind() const { return LaneKind; }
175
176 /// Returns true if this is the first lane of the whole vector.
177 bool isFirstLane() const { return Lane == 0 && LaneKind == Kind::First; }
178
179 /// Maps the lane to a cache index based on \p VF.
180 unsigned mapToCacheIndex(const ElementCount &VF) const {
181 switch (LaneKind) {
183 assert(VF.isScalable() && Lane < VF.getKnownMinValue() &&
184 "ScalableLast can only be used with scalable VFs");
185 return VF.getKnownMinValue() + Lane;
186 default:
187 assert(Lane < VF.getKnownMinValue() &&
188 "Cannot extract lane larger than VF");
189 return Lane;
190 }
191 }
192};
193
194/// VPTransformState holds information passed down when "executing" a VPlan,
195/// needed for generating the output IR.
200 Loop *CurrentParentLoop, Type *CanonicalIVTy);
201 /// Target Transform Info.
203
204 /// The chosen Vectorization Factor of the loop being vectorized.
206
207 /// Hold the index to generate specific scalar instructions. Null indicates
208 /// that all instances are to be generated, using either scalar or vector
209 /// instructions.
210 std::optional<VPLane> Lane;
211
212 struct DataState {
213 // Each value from the original loop, when vectorized, is represented by a
214 // vector value in the map.
216
219
220 /// Get the generated vector Value for a given VPValue \p Def if \p IsScalar
221 /// is false, otherwise return the generated scalar. \See set.
222 Value *get(VPValue *Def, bool IsScalar = false);
223
224 /// Get the generated Value for a given VPValue and given Part and Lane.
225 Value *get(VPValue *Def, const VPLane &Lane);
226
227 bool hasVectorValue(VPValue *Def) { return Data.VPV2Vector.contains(Def); }
228
230 auto I = Data.VPV2Scalars.find(Def);
231 if (I == Data.VPV2Scalars.end())
232 return false;
233 unsigned CacheIdx = Lane.mapToCacheIndex(VF);
234 return CacheIdx < I->second.size() && I->second[CacheIdx];
235 }
236
237 /// Set the generated vector Value for a given VPValue, if \p
238 /// IsScalar is false. If \p IsScalar is true, set the scalar in lane 0.
239 void set(VPValue *Def, Value *V, bool IsScalar = false) {
240 if (IsScalar) {
241 set(Def, V, VPLane(0));
242 return;
243 }
244 assert((VF.isScalar() || V->getType()->isVectorTy()) &&
245 "scalar values must be stored as (0, 0)");
246 Data.VPV2Vector[Def] = V;
247 }
248
249 /// Reset an existing vector value for \p Def and a given \p Part.
250 void reset(VPValue *Def, Value *V) {
251 assert(Data.VPV2Vector.contains(Def) && "need to overwrite existing value");
252 Data.VPV2Vector[Def] = V;
253 }
254
255 /// Set the generated scalar \p V for \p Def and the given \p Lane.
256 void set(VPValue *Def, Value *V, const VPLane &Lane) {
257 auto &Scalars = Data.VPV2Scalars[Def];
258 unsigned CacheIdx = Lane.mapToCacheIndex(VF);
259 if (Scalars.size() <= CacheIdx)
260 Scalars.resize(CacheIdx + 1);
261 assert(!Scalars[CacheIdx] && "should overwrite existing value");
262 Scalars[CacheIdx] = V;
263 }
264
265 /// Reset an existing scalar value for \p Def and a given \p Lane.
266 void reset(VPValue *Def, Value *V, const VPLane &Lane) {
267 auto Iter = Data.VPV2Scalars.find(Def);
268 assert(Iter != Data.VPV2Scalars.end() &&
269 "need to overwrite existing value");
270 unsigned CacheIdx = Lane.mapToCacheIndex(VF);
271 assert(CacheIdx < Iter->second.size() &&
272 "need to overwrite existing value");
273 Iter->second[CacheIdx] = V;
274 }
275
276 /// Add additional metadata to \p To that was not present on \p Orig.
277 ///
278 /// Currently this is used to add the noalias annotations based on the
279 /// inserted memchecks. Use this for instructions that are *cloned* into the
280 /// vector loop.
281 void addNewMetadata(Instruction *To, const Instruction *Orig);
282
283 /// Add metadata from one instruction to another.
284 ///
285 /// This includes both the original MDs from \p From and additional ones (\see
286 /// addNewMetadata). Use this for *newly created* instructions in the vector
287 /// loop.
288 void addMetadata(Value *To, Instruction *From);
289
290 /// Set the debug location in the builder using the debug location \p DL.
292
293 /// Construct the vector value of a scalarized value \p V one lane at a time.
294 void packScalarIntoVectorValue(VPValue *Def, const VPLane &Lane);
295
296 /// Hold state information used when constructing the CFG of the output IR,
297 /// traversing the VPBasicBlocks and generating corresponding IR BasicBlocks.
298 struct CFGState {
299 /// The previous VPBasicBlock visited. Initially set to null.
301
302 /// The previous IR BasicBlock created or used. Initially set to the new
303 /// header BasicBlock.
304 BasicBlock *PrevBB = nullptr;
305
306 /// The last IR BasicBlock in the output IR. Set to the exit block of the
307 /// vector loop.
308 BasicBlock *ExitBB = nullptr;
309
310 /// A mapping of each VPBasicBlock to the corresponding BasicBlock. In case
311 /// of replication, maps the BasicBlock of the last replica created.
313
314 /// Updater for the DominatorTree.
316
318 : DTU(DT, DomTreeUpdater::UpdateStrategy::Lazy) {}
319
320 /// Returns the BasicBlock* mapped to the pre-header of the loop region
321 /// containing \p R.
324
325 /// Hold a pointer to LoopInfo to register new basic blocks in the loop.
327
328 /// Hold a reference to the IRBuilder used to generate output IR code.
330
331 /// Hold a pointer to InnerLoopVectorizer to reuse its IR generation methods.
333
334 /// Pointer to the VPlan code is generated for.
336
337 /// The parent loop object for the current scope, or nullptr.
339
340 /// LoopVersioning. It's only set up (non-null) if memchecks were
341 /// used.
342 ///
343 /// This is currently only used to add no-alias metadata based on the
344 /// memchecks. The actually versioning is performed manually.
346
347 /// Map SCEVs to their expanded values. Populated when executing
348 /// VPExpandSCEVRecipes.
350
351 /// VPlan-based type analysis.
353};
354
355/// Struct to hold various analysis needed for cost computations.
364
368 : TTI(TTI), TLI(TLI), Types(CanIVTy), LLVMCtx(CanIVTy->getContext()),
369 CM(CM), CostKind(CostKind) {}
370
371 /// Return the cost for \p UI with \p VF using the legacy cost model as
372 /// fallback until computing the cost of all recipes migrates to VPlan.
374
375 /// Return true if the cost for \p UI shouldn't be computed, e.g. because it
376 /// has already been pre-computed.
377 bool skipCostComputation(Instruction *UI, bool IsVector) const;
378
379 /// Returns the OperandInfo for \p V, if it is a live-in.
381};
382
383/// This class can be used to assign names to VPValues. For VPValues without
384/// underlying value, assign consecutive numbers and use those as names (wrapped
385/// in vp<>). Otherwise, use the name from the underlying value (wrapped in
386/// ir<>), appending a .V version number if there are multiple uses of the same
387/// name. Allows querying names for VPValues for printing, similar to the
388/// ModuleSlotTracker for IR values.
390 /// Keep track of versioned names assigned to VPValues with underlying IR
391 /// values.
393 /// Keep track of the next number to use to version the base name.
394 StringMap<unsigned> BaseName2Version;
395
396 /// Number to assign to the next VPValue without underlying value.
397 unsigned NextSlot = 0;
398
399 void assignName(const VPValue *V);
400 void assignNames(const VPlan &Plan);
401 void assignNames(const VPBasicBlock *VPBB);
402
403public:
404 VPSlotTracker(const VPlan *Plan = nullptr) {
405 if (Plan)
406 assignNames(*Plan);
407 }
408
409 /// Returns the name assigned to \p V, if there is one, otherwise try to
410 /// construct one from the underlying value, if there's one; else return
411 /// <badref>.
412 std::string getOrCreateName(const VPValue *V) const;
413};
414
415#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
416/// VPlanPrinter prints a given VPlan to a given output stream. The printing is
417/// indented and follows the dot format.
419 raw_ostream &OS;
420 const VPlan &Plan;
421 unsigned Depth = 0;
422 unsigned TabWidth = 2;
423 std::string Indent;
424 unsigned BID = 0;
426
428
429 /// Handle indentation.
430 void bumpIndent(int b) { Indent = std::string((Depth += b) * TabWidth, ' '); }
431
432 /// Print a given \p Block of the Plan.
433 void dumpBlock(const VPBlockBase *Block);
434
435 /// Print the information related to the CFG edges going out of a given
436 /// \p Block, followed by printing the successor blocks themselves.
437 void dumpEdges(const VPBlockBase *Block);
438
439 /// Print a given \p BasicBlock, including its VPRecipes, followed by printing
440 /// its successor blocks.
441 void dumpBasicBlock(const VPBasicBlock *BasicBlock);
442
443 /// Print a given \p Region of the Plan.
444 void dumpRegion(const VPRegionBlock *Region);
445
446 unsigned getOrCreateBID(const VPBlockBase *Block) {
447 return BlockID.count(Block) ? BlockID[Block] : BlockID[Block] = BID++;
448 }
449
450 Twine getOrCreateName(const VPBlockBase *Block);
451
452 Twine getUID(const VPBlockBase *Block);
453
454 /// Print the information related to a CFG edge between two VPBlockBases.
455 void drawEdge(const VPBlockBase *From, const VPBlockBase *To, bool Hidden,
456 const Twine &Label);
457
458public:
460 : OS(O), Plan(P), SlotTracker(&P) {}
461
462 LLVM_DUMP_METHOD void dump();
463};
464#endif
465
466} // end namespace llvm
467
468#endif // LLVM_TRANSFORMS_VECTORIZE_VPLAN_H
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:622
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)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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.
LLVM Basic Block Representation.
Definition: BasicBlock.h:61
A debug info location.
Definition: DebugLoc.h:33
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:152
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Definition: Dominators.h:162
constexpr bool isScalar() const
Exactly one element.
Definition: TypeSize.h:322
Common base class shared among various IRBuilders.
Definition: IRBuilder.h:113
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:67
LoopVectorizationCostModel - estimates the expected speedups due to vectorization.
This class emits a version of the loop where run-time checks ensure that may-alias pointers can't ove...
Represents a single loop in the control flow graph.
Definition: LoopInfo.h:39
This class provides computation of slot numbers for LLVM Assembly writing.
Definition: AsmWriter.cpp:698
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
Definition: SmallPtrSet.h:519
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Definition: StringMap.h:128
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.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
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:86
ElementCount operator*() const
Definition: VPlanHelpers.h:94
iterator & operator++()
Definition: VPlanHelpers.h:96
iterator(ElementCount VF)
Definition: VPlanHelpers.h:90
bool operator==(const iterator &Other) const
Definition: VPlanHelpers.h:92
VPBasicBlock serves as the leaf of the Hierarchical Control-Flow Graph.
Definition: VPlan.h:3200
VPBlockBase is the building block of the Hierarchical Control-Flow Graph.
Definition: VPlan.h:78
In what follows, the term "input IR" refers to code that is fed into the vectorizer whereas the term ...
Definition: VPlanHelpers.h:116
static VPLane getLastLaneForVF(const ElementCount &VF)
Definition: VPlanHelpers.h:157
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:139
Kind getKind() const
Returns the Kind of lane offset.
Definition: VPlanHelpers.h:174
static VPLane getLaneFromEnd(const ElementCount &VF, unsigned Offset)
Definition: VPlanHelpers.h:143
bool isFirstLane() const
Returns true if this is the first lane of the whole vector.
Definition: VPlanHelpers.h:177
VPLane(unsigned Lane)
Definition: VPlanHelpers.h:138
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:163
static VPLane getFirstLane()
Definition: VPlanHelpers.h:141
Kind
Kind describes how to interpret Lane.
Definition: VPlanHelpers.h:119
@ 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:180
VPRecipeBase is a base class modeling a sequence of one or more output IR instructions.
Definition: VPlan.h:366
VPRegionBlock represents a collection of VPBasicBlocks and VPRegionBlocks which form a Single-Entry-S...
Definition: VPlan.h:3377
This class can be used to assign names to VPValues.
Definition: VPlanHelpers.h:389
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:1544
VPSlotTracker(const VPlan *Plan=nullptr)
Definition: VPlanHelpers.h:404
An analysis for type-inference for VPValues.
Definition: VPlanAnalysis.h:40
VPlanPrinter prints a given VPlan to a given output stream.
Definition: VPlanHelpers.h:418
VPlanPrinter(raw_ostream &O, const VPlan &P)
Definition: VPlanHelpers.h:459
LLVM_DUMP_METHOD void dump()
Definition: VPlan.cpp:1292
VPlan models a candidate for vectorization, encoding various decisions take to produce efficient outp...
Definition: VPlan.h:3476
LLVM Value Representation.
Definition: Value.h:74
constexpr bool isScalable() const
Returns whether the quantity is scaled by a runtime quantity (vscale).
Definition: TypeSize.h:171
constexpr ScalarTy getKnownMinValue() const
Returns the minimum value this quantity can represent.
Definition: TypeSize.h:168
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:52
@ BasicBlock
Various leaf nodes.
Definition: ISDOpcodes.h:71
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Offset
Definition: DWP.cpp:480
Value * getRuntimeVF(IRBuilderBase &B, Type *Ty, ElementCount VF)
Return the runtime value for VF.
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
Definition: MathExtras.h:292
@ Other
Any other memory.
Value * createStepForVF(IRBuilderBase &B, Type *Ty, ElementCount VF, int64_t Step)
Return a value for Step multiplied by VF.
unsigned getReciprocalPredBlockProb()
A helper function that returns the reciprocal of the block probability of predicated blocks.
Definition: VPlanHelpers.h:57
A range of powers-of-2 vectorization factors with fixed start and adjustable end.
Definition: VPlanHelpers.h:62
iterator end()
Definition: VPlanHelpers.h:103
const ElementCount Start
Definition: VPlanHelpers.h:64
ElementCount End
Definition: VPlanHelpers.h:67
iterator begin()
Definition: VPlanHelpers.h:102
bool isEmpty() const
Definition: VPlanHelpers.h:69
VFRange(const ElementCount &Start, const ElementCount &End)
Definition: VPlanHelpers.h:73
Struct to hold various analysis needed for cost computations.
Definition: VPlanHelpers.h:356
LLVMContext & LLVMCtx
Definition: VPlanHelpers.h:360
LoopVectorizationCostModel & CM
Definition: VPlanHelpers.h:361
VPCostContext(const TargetTransformInfo &TTI, const TargetLibraryInfo &TLI, Type *CanIVTy, LoopVectorizationCostModel &CM, TargetTransformInfo::TargetCostKind CostKind)
Definition: VPlanHelpers.h:365
TargetTransformInfo::OperandValueInfo getOperandInfo(VPValue *V) const
Returns the OperandInfo for V, if it is a live-in.
Definition: VPlan.cpp:1634
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:363
VPTypeAnalysis Types
Definition: VPlanHelpers.h:359
const TargetLibraryInfo & TLI
Definition: VPlanHelpers.h:358
const TargetTransformInfo & TTI
Definition: VPlanHelpers.h:357
SmallPtrSet< Instruction *, 8 > SkipCostComputation
Definition: VPlanHelpers.h:362
Hold state information used when constructing the CFG of the output IR, traversing the VPBasicBlocks ...
Definition: VPlanHelpers.h:298
BasicBlock * PrevBB
The previous IR BasicBlock created or used.
Definition: VPlanHelpers.h:304
SmallDenseMap< VPBasicBlock *, BasicBlock * > VPBB2IRBB
A mapping of each VPBasicBlock to the corresponding BasicBlock.
Definition: VPlanHelpers.h:312
VPBasicBlock * PrevVPBB
The previous VPBasicBlock visited. Initially set to null.
Definition: VPlanHelpers.h:300
BasicBlock * ExitBB
The last IR BasicBlock in the output IR.
Definition: VPlanHelpers.h:308
BasicBlock * getPreheaderBBFor(VPRecipeBase *R)
Returns the BasicBlock* mapped to the pre-header of the loop region containing R.
Definition: VPlan.cpp:349
DomTreeUpdater DTU
Updater for the DominatorTree.
Definition: VPlanHelpers.h:315
DenseMap< VPValue *, Value * > VPV2Vector
Definition: VPlanHelpers.h:215
DenseMap< VPValue *, SmallVector< Value *, 4 > > VPV2Scalars
Definition: VPlanHelpers.h:217
VPTransformState holds information passed down when "executing" a VPlan, needed for generating the ou...
Definition: VPlanHelpers.h:196
bool hasScalarValue(VPValue *Def, VPLane Lane)
Definition: VPlanHelpers.h:229
bool hasVectorValue(VPValue *Def)
Definition: VPlanHelpers.h:227
LoopInfo * LI
Hold a pointer to LoopInfo to register new basic blocks in the loop.
Definition: VPlanHelpers.h:326
DenseMap< const SCEV *, Value * > ExpandedSCEVs
Map SCEVs to their expanded values.
Definition: VPlanHelpers.h:349
VPTypeAnalysis TypeAnalysis
VPlan-based type analysis.
Definition: VPlanHelpers.h:352
struct llvm::VPTransformState::DataState Data
void addMetadata(Value *To, Instruction *From)
Add metadata from one instruction to another.
Definition: VPlan.cpp:362
void packScalarIntoVectorValue(VPValue *Def, const VPLane &Lane)
Construct the vector value of a scalarized value V one lane at a time.
Definition: VPlan.cpp:395
Value * get(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:251
struct llvm::VPTransformState::CFGState CFG
LoopVersioning * LVer
LoopVersioning.
Definition: VPlanHelpers.h:345
void addNewMetadata(Instruction *To, const Instruction *Orig)
Add additional metadata to To that was not present on Orig.
Definition: VPlan.cpp:354
void reset(VPValue *Def, Value *V, const VPLane &Lane)
Reset an existing scalar value for Def and a given Lane.
Definition: VPlanHelpers.h:266
std::optional< VPLane > Lane
Hold the index to generate specific scalar instructions.
Definition: VPlanHelpers.h:210
void set(VPValue *Def, Value *V, const VPLane &Lane)
Set the generated scalar V for Def and the given Lane.
Definition: VPlanHelpers.h:256
IRBuilderBase & Builder
Hold a reference to the IRBuilder used to generate output IR code.
Definition: VPlanHelpers.h:329
const TargetTransformInfo * TTI
Target Transform Info.
Definition: VPlanHelpers.h:202
VPlan * Plan
Pointer to the VPlan code is generated for.
Definition: VPlanHelpers.h:335
InnerLoopVectorizer * ILV
Hold a pointer to InnerLoopVectorizer to reuse its IR generation methods.
Definition: VPlanHelpers.h:332
void reset(VPValue *Def, Value *V)
Reset an existing vector value for Def and a given Part.
Definition: VPlanHelpers.h:250
ElementCount VF
The chosen Vectorization Factor of the loop being vectorized.
Definition: VPlanHelpers.h:205
void setDebugLocFrom(DebugLoc DL)
Set the debug location in the builder using the debug location DL.
Definition: VPlan.cpp:373
Loop * CurrentParentLoop
The parent loop object for the current scope, or nullptr.
Definition: VPlanHelpers.h:338
void set(VPValue *Def, Value *V, bool IsScalar=false)
Set the generated vector Value for a given VPValue, if IsScalar is false.
Definition: VPlanHelpers.h:239