15#ifndef LLVM_TRANSFORMS_VECTORIZE_VPLANHELPERS_H
16#define LLVM_TRANSFORMS_VECTORIZE_VPLANHELPERS_H
34class InnerLoopVectorizer;
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");
148 VPLane(
unsigned Lane,
Kind LaneKind) : Lane(Lane), LaneKind(LaneKind) {}
154 "trying to extract with invalid offset");
163 return VPLane(LaneOffset, LaneKind);
174 "can only get known lane from the beginning");
193 "ScalableLast can only be used with scalable VFs");
197 "Cannot extract lane larger than VF");
209 Type *CanonicalIVTy);
244 unsigned CacheIdx =
Lane.mapToCacheIndex(
VF);
245 return CacheIdx <
I->second.size() &&
I->second[CacheIdx];
256 "scalar values must be stored as (0, 0)");
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;
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;
390 unsigned NextSlot = 0;
394 std::unique_ptr<ModuleSlotTracker> MST;
396 void assignName(
const VPValue *V);
397 void assignNames(
const VPlan &Plan);
399 std::string getName(
const Value *V);
413#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
420 unsigned TabWidth = 2;
428 void bumpIndent(
int b) { Indent = std::string((
Depth += b) * TabWidth,
' '); }
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")
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
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,...
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.
A cache of @llvm.assume calls within a function.
LLVM Basic Block Representation.
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
constexpr bool isScalar() const
Exactly one element.
Common base class shared among various IRBuilders.
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 provides computation of slot numbers for LLVM Assembly writing.
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.
VPlanPrinter prints a given VPlan to a given output stream.
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.
@ BasicBlock
Various leaf nodes.
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.
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.
A range of powers-of-2 vectorization factors with fixed start and adjustable end.
VFRange(const ElementCount &Start, const ElementCount &End)
Struct to hold various analysis needed for cost computations.
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 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
const TargetLibraryInfo & TLI
const TargetTransformInfo & TTI
VPCostContext(const TargetTransformInfo &TTI, const TargetLibraryInfo &TLI, const VPlan &Plan, LoopVectorizationCostModel &CM, TargetTransformInfo::TargetCostKind CostKind)
SmallPtrSet< Instruction *, 8 > SkipCostComputation