15#ifndef LLVM_TRANSFORMS_VECTORIZE_VPLANHELPERS_H
16#define LLVM_TRANSFORMS_VECTORIZE_VPLANHELPERS_H
64 return End.getKnownMinValue() <=
Start.getKnownMinValue();
70 "Both Start and End should have the same scalable flag");
72 "Expected Start to be a power of 2");
74 "Expected End to be a power of 2");
133 VPLane(
unsigned Lane,
Kind LaneKind) : Lane(Lane), LaneKind(LaneKind) {}
139 "trying to extract with invalid offset");
148 return VPLane(LaneOffset, LaneKind);
159 "can only get known lane from the beginning");
178 "ScalableLast can only be used with scalable VFs");
182 "Cannot extract lane larger than VF");
194 Type *CanonicalIVTy);
222 return Data.VPV2Vector.contains(Def);
226 auto I =
Data.VPV2Scalars.find(Def);
227 if (
I ==
Data.VPV2Scalars.end())
229 unsigned CacheIdx =
Lane.mapToCacheIndex(
VF);
230 return CacheIdx <
I->second.size() &&
I->second[CacheIdx];
241 "scalar values must be stored as (0, 0)");
242 Data.VPV2Vector[Def] = V;
247 assert(
Data.VPV2Vector.contains(Def) &&
"need to overwrite existing value");
248 Data.VPV2Vector[Def] = V;
253 auto &Scalars =
Data.VPV2Scalars[Def];
254 unsigned CacheIdx =
Lane.mapToCacheIndex(
VF);
255 if (Scalars.size() <= CacheIdx)
256 Scalars.resize(CacheIdx + 1);
257 assert(!Scalars[CacheIdx] &&
"should overwrite existing value");
258 Scalars[CacheIdx] = V;
263 auto Iter =
Data.VPV2Scalars.find(Def);
265 "need to overwrite existing value");
266 unsigned CacheIdx =
Lane.mapToCacheIndex(
VF);
267 assert(CacheIdx < Iter->second.size() &&
268 "need to overwrite existing value");
269 Iter->second[CacheIdx] = V;
374 bool AlwaysIncludeReplicatingR =
false);
391 unsigned NextSlot = 0;
395 std::unique_ptr<ModuleSlotTracker> MST;
397 void assignName(
const VPValue *V);
398 void assignNames(
const VPlan &Plan);
400 std::string getName(
const Value *V);
414#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
421 unsigned TabWidth = 2;
429 void bumpIndent(
int b) { Indent = std::string((Depth += b) * TabWidth,
' '); }
459 : OS(O), Plan(
P), SlotTracker(&
P) {}
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.
This file defines the DenseMap class.
This file defines an InstructionCost class that is used when calculating the cost of an instruction,...
This file defines the SmallPtrSet class.
This file defines the SmallVector class.
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),...
A cache of @llvm.assume calls within a function.
LLVM Basic Block Representation.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Common base class shared among various IRBuilders.
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.
LoopVectorizationCostModel - estimates the expected speedups due to vectorization.
Represents a single loop in the control flow graph.
This class represents an analyzed expression in the program.
The main scalar evolution driver.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Provides information about what library functions are available for the current target.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
The instances of the Type class are immutable: once they are created, they are never changed.
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.
VPBlockBase is the building block of the Hierarchical Control-Flow Graph.
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.
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.
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...
This class can be used to assign names to VPValues.
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...
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,...
VPlanPrinter(raw_ostream &O, const VPlan &P)
LLVM_DUMP_METHOD void dump()
VPlan models a candidate for vectorization, encoding various decisions take to produce efficient outp...
LLVM Value Representation.
constexpr bool isScalable() const
Returns whether the quantity is scaled by a runtime quantity (vscale).
constexpr ScalarTy getKnownMinValue() const
Returns the minimum value this quantity can represent.
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
This class implements an extremely fast bulk output stream that can only output to a stream.
This is an optimization pass for GlobalISel generic memory operations.
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.
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...
FunctionAddr VTableAddr uintptr_t uintptr_t Data
Value * createStepForVF(IRBuilderBase &B, Type *Ty, ElementCount VF, int64_t Step)
Return a value for Step multiplied by VF.
VFRange(const ElementCount &Start, const ElementCount &End)
unsigned getPredBlockCostDivisor(BasicBlock *BB) const
LoopVectorizationCostModel & CM
TargetTransformInfo::OperandValueInfo getOperandInfo(VPValue *V) const
Returns the OperandInfo for V, if it is a live-in.
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 getScalarizationOverhead(Type *ResultTy, ArrayRef< const VPValue * > Operands, ElementCount VF, bool AlwaysIncludeReplicatingR=false)
Estimate the overhead of scalarizing a recipe with result type ResultTy and Operands with VF.
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...
VPCostContext(const TargetTransformInfo &TTI, const TargetLibraryInfo &TLI, const VPlan &Plan, LoopVectorizationCostModel &CM, TargetTransformInfo::TargetCostKind CostKind, ScalarEvolution &SE, const Loop *L)
TargetTransformInfo::TargetCostKind CostKind
const TargetLibraryInfo & TLI
const TargetTransformInfo & TTI
SmallPtrSet< Instruction *, 8 > SkipCostComputation