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/// A range of powers-of-2 vectorization factors with fixed start and
50/// adjustable end. The range includes start and excludes end, e.g.,:
51/// [1, 16) = {1, 2, 4, 8}
52struct VFRange {
53 // A power of 2.
55
56 // A power of 2. If End <= Start range is empty.
58
59 bool isEmpty() const {
60 return End.getKnownMinValue() <= Start.getKnownMinValue();
61 }
62
64 : Start(Start), End(End) {
65 assert(Start.isScalable() == End.isScalable() &&
66 "Both Start and End should have the same scalable flag");
67 assert(isPowerOf2_32(Start.getKnownMinValue()) &&
68 "Expected Start to be a power of 2");
69 assert(isPowerOf2_32(End.getKnownMinValue()) &&
70 "Expected End to be a power of 2");
71 }
72
73 /// Iterator to iterate over vectorization factors in a VFRange.
75 : public iterator_facade_base<iterator, std::forward_iterator_tag,
76 ElementCount> {
77 ElementCount VF;
78
79 public:
80 iterator(ElementCount VF) : VF(VF) {}
81
82 bool operator==(const iterator &Other) const { return VF == Other.VF; }
83
84 ElementCount operator*() const { return VF; }
85
87 VF *= 2;
88 return *this;
89 }
90 };
91
94 assert(isPowerOf2_32(End.getKnownMinValue()));
95 return iterator(End);
96 }
97};
98
99/// In what follows, the term "input IR" refers to code that is fed into the
100/// vectorizer whereas the term "output IR" refers to code that is generated by
101/// the vectorizer.
102
103/// VPLane provides a way to access lanes in both fixed width and scalable
104/// vectors, where for the latter the lane index sometimes needs calculating
105/// as a runtime expression.
106class VPLane {
107public:
108 /// Kind describes how to interpret Lane.
109 enum class Kind : uint8_t {
110 /// For First, Lane is the index into the first N elements of a
111 /// fixed-vector <N x <ElTy>> or a scalable vector <vscale x N x <ElTy>>.
113 /// For ScalableLast, Lane is the offset from the start of the last
114 /// N-element subvector in a scalable vector <vscale x N x <ElTy>>. For
115 /// example, a Lane of 0 corresponds to lane `(vscale - 1) * N`, a Lane of
116 /// 1 corresponds to `((vscale - 1) * N) + 1`, etc.
118 };
119
120private:
121 /// in [0..VF)
122 unsigned Lane;
123
124 /// Indicates how the Lane should be interpreted, as described above.
125 Kind LaneKind = Kind::First;
126
127public:
128 VPLane(unsigned Lane) : Lane(Lane) {}
129 VPLane(unsigned Lane, Kind LaneKind) : Lane(Lane), LaneKind(LaneKind) {}
130
132
133 static VPLane getLaneFromEnd(const ElementCount &VF, unsigned Offset) {
134 assert(Offset > 0 && Offset <= VF.getKnownMinValue() &&
135 "trying to extract with invalid offset");
136 unsigned LaneOffset = VF.getKnownMinValue() - Offset;
137 Kind LaneKind;
138 if (VF.isScalable())
139 // In this case 'LaneOffset' refers to the offset from the start of the
140 // last subvector with VF.getKnownMinValue() elements.
142 else
143 LaneKind = VPLane::Kind::First;
144 return VPLane(LaneOffset, LaneKind);
145 }
146
148 return getLaneFromEnd(VF, 1);
149 }
150
151 /// Returns a compile-time known value for the lane index and asserts if the
152 /// lane can only be calculated at runtime.
153 unsigned getKnownLane() const {
154 assert(LaneKind == Kind::First &&
155 "can only get known lane from the beginning");
156 return Lane;
157 }
158
159 /// Returns an expression describing the lane index that can be used at
160 /// runtime.
161 Value *getAsRuntimeExpr(IRBuilderBase &Builder, const ElementCount &VF) const;
162
163 /// Returns the Kind of lane offset.
164 Kind getKind() const { return LaneKind; }
165
166 /// Returns true if this is the first lane of the whole vector.
167 bool isFirstLane() const { return Lane == 0 && LaneKind == Kind::First; }
168
169 /// Maps the lane to a cache index based on \p VF.
170 unsigned mapToCacheIndex(const ElementCount &VF) const {
171 switch (LaneKind) {
173 assert(VF.isScalable() && Lane < VF.getKnownMinValue() &&
174 "ScalableLast can only be used with scalable VFs");
175 return VF.getKnownMinValue() + Lane;
176 default:
177 assert(Lane < VF.getKnownMinValue() &&
178 "Cannot extract lane larger than VF");
179 return Lane;
180 }
181 }
182};
183
184/// VPTransformState holds information passed down when "executing" a VPlan,
185/// needed for generating the output IR.
190 Type *CanonicalIVTy);
191 /// Target Transform Info.
193
194 /// The chosen Vectorization Factor of the loop being vectorized.
196
197 /// Hold the index to generate specific scalar instructions. Null indicates
198 /// that all instances are to be generated, using either scalar or vector
199 /// instructions.
200 /// TODO: This is now only used in asserts. Remove as follow-up.
201 std::optional<VPLane> Lane;
202
203 struct DataState {
204 // Each value from the original loop, when vectorized, is represented by a
205 // vector value in the map.
207
210
211 /// Get the generated vector Value for a given VPValue \p Def if \p IsScalar
212 /// is false, otherwise return the generated scalar. \See set.
213 Value *get(const VPValue *Def, bool IsScalar = false);
214
215 /// Get the generated Value for a given VPValue and given Part and Lane.
216 Value *get(const VPValue *Def, const VPLane &Lane);
217
218 bool hasVectorValue(const VPValue *Def) {
219 return Data.VPV2Vector.contains(Def);
220 }
221
222 bool hasScalarValue(const VPValue *Def, VPLane Lane) {
223 auto I = Data.VPV2Scalars.find(Def);
224 if (I == Data.VPV2Scalars.end())
225 return false;
226 unsigned CacheIdx = Lane.mapToCacheIndex(VF);
227 return CacheIdx < I->second.size() && I->second[CacheIdx];
228 }
229
230 /// Set the generated vector Value for a given VPValue, if \p
231 /// IsScalar is false. If \p IsScalar is true, set the scalar in lane 0.
232 void set(const VPValue *Def, Value *V, bool IsScalar = false) {
233 if (IsScalar) {
234 set(Def, V, VPLane(0));
235 return;
236 }
237 assert((VF.isScalar() || isVectorizedTy(V->getType())) &&
238 "scalar values must be stored as (0, 0)");
239 Data.VPV2Vector[Def] = V;
240 }
241
242 /// Reset an existing vector value for \p Def and a given \p Part.
243 void reset(const VPValue *Def, Value *V) {
244 assert(Data.VPV2Vector.contains(Def) && "need to overwrite existing value");
245 Data.VPV2Vector[Def] = V;
246 }
247
248 /// Set the generated scalar \p V for \p Def and the given \p Lane.
249 void set(const VPValue *Def, Value *V, const VPLane &Lane) {
250 auto &Scalars = Data.VPV2Scalars[Def];
251 unsigned CacheIdx = Lane.mapToCacheIndex(VF);
252 if (Scalars.size() <= CacheIdx)
253 Scalars.resize(CacheIdx + 1);
254 assert(!Scalars[CacheIdx] && "should overwrite existing value");
255 Scalars[CacheIdx] = V;
256 }
257
258 /// Reset an existing scalar value for \p Def and a given \p Lane.
259 void reset(const VPValue *Def, Value *V, const VPLane &Lane) {
260 auto Iter = Data.VPV2Scalars.find(Def);
261 assert(Iter != Data.VPV2Scalars.end() &&
262 "need to overwrite existing value");
263 unsigned CacheIdx = Lane.mapToCacheIndex(VF);
264 assert(CacheIdx < Iter->second.size() &&
265 "need to overwrite existing value");
266 Iter->second[CacheIdx] = V;
267 }
268
269 /// Set the debug location in the builder using the debug location \p DL.
271
272 /// Insert the scalar value of \p Def at \p Lane into \p Lane of \p WideValue
273 /// and return the resulting value.
274 Value *packScalarIntoVectorizedValue(const VPValue *Def, Value *WideValue,
275 const VPLane &Lane);
276
277 /// Hold state information used when constructing the CFG of the output IR,
278 /// traversing the VPBasicBlocks and generating corresponding IR BasicBlocks.
279 struct CFGState {
280 /// The previous VPBasicBlock visited. Initially set to null.
282
283 /// The previous IR BasicBlock created or used. Initially set to the new
284 /// header BasicBlock.
285 BasicBlock *PrevBB = nullptr;
286
287 /// The last IR BasicBlock in the output IR. Set to the exit block of the
288 /// vector loop.
289 BasicBlock *ExitBB = nullptr;
290
291 /// A mapping of each VPBasicBlock to the corresponding BasicBlock. In case
292 /// of replication, maps the BasicBlock of the last replica created.
294
295 /// Updater for the DominatorTree.
297
299 : DTU(DT, DomTreeUpdater::UpdateStrategy::Lazy) {}
301
302 /// Hold a pointer to LoopInfo to register new basic blocks in the loop.
304
305 /// Hold a pointer to AssumptionCache to register new assumptions after
306 /// replicating assume calls.
308
309 /// Hold a reference to the IRBuilder used to generate output IR code.
311
312 /// Pointer to the VPlan code is generated for.
314
315 /// The parent loop object for the current scope, or nullptr.
317
318 /// VPlan-based type analysis.
320
321 /// VPlan-based dominator tree.
323};
324
325/// Struct to hold various analysis needed for cost computations.
335 const Loop *L;
336
337 /// Number of predicated stores in the VPlan, computed on demand.
338 std::optional<unsigned> NumPredStores;
339
346
347 /// Return the cost for \p UI with \p VF using the legacy cost model as
348 /// fallback until computing the cost of all recipes migrates to VPlan.
350
351 /// Return true if the cost for \p UI shouldn't be computed, e.g. because it
352 /// has already been pre-computed.
353 bool skipCostComputation(Instruction *UI, bool IsVector) const;
354
355 /// \returns how much the cost of a predicated block should be divided by.
356 /// Forwards to LoopVectorizationCostModel::getPredBlockCostDivisor.
358
359 /// Returns the OperandInfo for \p V, if it is a live-in.
361
362 /// Estimate the overhead of scalarizing a recipe with result type \p ResultTy
363 /// and \p Operands with \p VF. This is a convenience wrapper for the
364 /// type-based getScalarizationOverhead API. \p VIC provides context about
365 /// whether the scalarization is for a load/store operation. If \p
366 /// AlwaysIncludeReplicatingR is true, always compute the cost of scalarizing
367 /// replicating operands.
369 Type *ResultTy, ArrayRef<const VPValue *> Operands, ElementCount VF,
371 bool AlwaysIncludeReplicatingR = false);
372
373 /// Returns true if an artificially high cost for emulated masked memrefs
374 /// should be used.
376
377 /// Returns true if \p ID is a pseudo intrinsic that is dropped via
378 /// scalarization rather than widened.
380};
381
382/// This class can be used to assign names to VPValues. For VPValues without
383/// underlying value, assign consecutive numbers and use those as names (wrapped
384/// in vp<>). Otherwise, use the name from the underlying value (wrapped in
385/// ir<>), appending a .V version number if there are multiple uses of the same
386/// name. Allows querying names for VPValues for printing, similar to the
387/// ModuleSlotTracker for IR values.
389 /// Keep track of versioned names assigned to VPValues with underlying IR
390 /// values.
392 /// Keep track of the next number to use to version the base name.
393 StringMap<unsigned> BaseName2Version;
394
395 /// Number to assign to the next VPValue without underlying value.
396 unsigned NextSlot = 0;
397
398 /// Lazily created ModuleSlotTracker, used only when unnamed IR instructions
399 /// require slot tracking.
400 std::unique_ptr<ModuleSlotTracker> MST;
401
402 /// Cached metadata kind names from the Module's LLVMContext.
404
405 /// Cached Module pointer for printing metadata.
406 const Module *M = nullptr;
407
408 void assignName(const VPValue *V);
409 LLVM_ABI_FOR_TEST void assignNames(const VPlan &Plan);
410 void assignNames(const VPBasicBlock *VPBB);
411 std::string getName(const Value *V);
412
413public:
414 VPSlotTracker(const VPlan *Plan = nullptr) {
415 if (Plan) {
416 assignNames(*Plan);
417 if (auto *ScalarHeader = Plan->getScalarHeader())
418 M = ScalarHeader->getIRBasicBlock()->getModule();
419 }
420 }
421
422 /// Returns the name assigned to \p V, if there is one, otherwise try to
423 /// construct one from the underlying value, if there's one; else return
424 /// <badref>.
425 std::string getOrCreateName(const VPValue *V) const;
426
427 /// Returns the cached metadata kind names.
429 if (MDNames.empty() && M)
430 M->getContext().getMDKindNames(MDNames);
431 return MDNames;
432 }
433
434 /// Returns the cached Module pointer.
435 const Module *getModule() const { return M; }
436};
437
438#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
439/// VPlanPrinter prints a given VPlan to a given output stream. The printing is
440/// indented and follows the dot format.
442 raw_ostream &OS;
443 const VPlan &Plan;
444 unsigned Depth = 0;
445 unsigned TabWidth = 2;
446 std::string Indent;
447 unsigned BID = 0;
449
450 VPSlotTracker SlotTracker;
451
452 /// Handle indentation.
453 void bumpIndent(int b) { Indent = std::string((Depth += b) * TabWidth, ' '); }
454
455 /// Print a given \p Block of the Plan.
456 void dumpBlock(const VPBlockBase *Block);
457
458 /// Print the information related to the CFG edges going out of a given
459 /// \p Block, followed by printing the successor blocks themselves.
460 void dumpEdges(const VPBlockBase *Block);
461
462 /// Print a given \p BasicBlock, including its VPRecipes, followed by printing
463 /// its successor blocks.
464 void dumpBasicBlock(const VPBasicBlock *BasicBlock);
465
466 /// Print a given \p Region of the Plan.
467 void dumpRegion(const VPRegionBlock *Region);
468
469 unsigned getOrCreateBID(const VPBlockBase *Block) {
470 return BlockID.count(Block) ? BlockID[Block] : BlockID[Block] = BID++;
471 }
472
473 Twine getOrCreateName(const VPBlockBase *Block);
474
475 Twine getUID(const VPBlockBase *Block);
476
477 /// Print the information related to a CFG edge between two VPBlockBases.
478 void drawEdge(const VPBlockBase *From, const VPBlockBase *To, bool Hidden,
479 const Twine &Label);
480
481public:
483 : OS(O), Plan(P), SlotTracker(&P) {}
484
485 LLVM_DUMP_METHOD void dump();
486};
487#endif
488
489/// Check if a constant \p CI can be safely treated as having been extended
490/// from a narrower type with the given extension kind.
491bool canConstantBeExtended(const APInt *C, Type *NarrowType,
493} // end namespace llvm
494
495#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.
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
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:4146
VPBlockBase is the building block of the Hierarchical Control-Flow Graph.
Definition VPlan.h:97
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:88
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:4356
VPReplicateRecipe replicates a given instruction producing multiple scalar copies of the original sca...
Definition VPlan.h:3194
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:1624
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:49
VPlanPrinter(raw_ostream &O, const VPlan &P)
LLVM_DUMP_METHOD void dump()
Definition VPlan.cpp:1339
VPlan models a candidate for vectorization, encoding various decisions take to produce efficient outp...
Definition VPlan.h:4504
VPIRBasicBlock * getScalarHeader() const
Return the VPIRBasicBlock wrapping the header of the scalar loop.
Definition VPlan.h:4649
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
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition CallingConv.h:24
This is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:557
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:1851
@ Other
Any other memory.
Definition ModRef.h:68
FunctionAddr VTableAddr uintptr_t uintptr_t Data
Definition InstrProf.h:221
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:1862
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:1947
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:1869
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:1907
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:280
VPTransformState(const TargetTransformInfo *TTI, ElementCount VF, LoopInfo *LI, DominatorTree *DT, AssumptionCache *AC, IRBuilderBase &Builder, VPlan *Plan, Loop *CurrentParentLoop, Type *CanonicalIVTy)
Definition VPlan.cpp:240
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:362
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:340
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.