LLVM 24.0.0git
SLPCostAnalysis.cpp
Go to the documentation of this file.
1//===- SLPCostAnalysis.cpp - SLP Vectorizer free cost 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#include "SLPCostAnalysis.h"
10#include "SLPTypeUtils.h"
11#include "SLPUtils.h"
12
13#include "llvm/ADT/APInt.h"
14#include "llvm/ADT/STLExtras.h"
15#include "llvm/ADT/Sequence.h"
18#include "llvm/IR/Constants.h"
22#include "llvm/IR/Operator.h"
24#include "llvm/IR/Type.h"
25#include "llvm/IR/Value.h"
28
29#include <cassert>
30#include <utility>
31
32using namespace llvm;
33using namespace llvm::PatternMatch;
34
35namespace llvm::slpvectorizer {
36
40 ArrayRef<int> Mask, int Index, VectorType *SubTp,
42 VectorType *DstTy = Tp;
43 if (!Mask.empty())
44 DstTy = FixedVectorType::get(Tp->getScalarType(), Mask.size());
45
46 if (Kind != TTI::SK_PermuteTwoSrc)
47 return TTI.getShuffleCost(Kind, DstTy, Tp, CostKind, Mask, Index, SubTp,
48 Args);
49 int NumSrcElts = Tp->getElementCount().getKnownMinValue();
50 int NumSubElts;
51 if (Mask.size() > 2 && ShuffleVectorInst::isInsertSubvectorMask(
52 Mask, NumSrcElts, NumSubElts, Index)) {
53 if (Index + NumSubElts > NumSrcElts &&
54 Index + NumSrcElts <= static_cast<int>(Mask.size()))
55 return TTI.getShuffleCost(TTI::SK_InsertSubvector, DstTy, Tp, CostKind,
56 Mask, Index, Tp);
57 }
58 return TTI.getShuffleCost(Kind, DstTy, Tp, CostKind, Mask, Index, SubTp,
59 Args);
60}
61
62std::pair<InstructionCost, InstructionCost>
64 Value *BasePtr, unsigned Opcode, const TTI::TargetCostKind CostKind,
65 Type *ScalarTy, VectorType *VecTy) {
66 InstructionCost ScalarCost = 0;
67 InstructionCost VecCost = 0;
68 // Here we differentiate two cases: (1) when Ptrs represent a regular
69 // vectorization tree node (as they are pointer arguments of scattered
70 // loads) or (2) when Ptrs are the arguments of loads or stores being
71 // vectorized as plane wide unit-stride load/store since all the
72 // loads/stores are known to be from/to adjacent locations.
73 if (Opcode == Instruction::Load || Opcode == Instruction::Store) {
74 // Case 2: estimate costs for pointer related costs when vectorizing to
75 // a wide load/store.
76 // Scalar cost is estimated as a set of pointers with known relationship
77 // between them.
78 // For vector code we will use BasePtr as argument for the wide load/store
79 // but we also need to account all the instructions which are going to
80 // stay in vectorized code due to uses outside of these scalar
81 // loads/stores.
82 ScalarCost = TTI.getPointersChainCost(
83 Ptrs, BasePtr, TTI::PointersChainInfo::getUnitStride(), ScalarTy,
84 CostKind);
85
86 SmallVector<const Value *> PtrsRetainedInVecCode;
87 for (Value *V : Ptrs) {
88 if (V == BasePtr) {
89 PtrsRetainedInVecCode.push_back(V);
90 continue;
91 }
92 auto *Ptr = dyn_cast<GetElementPtrInst>(V);
93 // For simplicity assume Ptr to stay in vectorized code if it's not a
94 // GEP instruction. We don't care since it's cost considered free.
95 // TODO: We should check for any uses outside of vectorizable tree
96 // rather than just single use.
97 if (!Ptr || !Ptr->hasOneUse())
98 PtrsRetainedInVecCode.push_back(V);
99 }
100
101 if (PtrsRetainedInVecCode.size() == Ptrs.size()) {
102 // If all pointers stay in vectorized code then we don't have
103 // any savings on that.
104 return std::make_pair(TTI::TCC_Free, TTI::TCC_Free);
105 }
106 VecCost = TTI.getPointersChainCost(PtrsRetainedInVecCode, BasePtr,
107 TTI::PointersChainInfo::getKnownStride(),
108 VecTy, CostKind);
109 } else {
110 // Case 1: Ptrs are the arguments of loads that we are going to transform
111 // into masked gather load intrinsic.
112 // All the scalar GEPs will be removed as a result of vectorization.
113 // For any external uses of some lanes extract element instructions will
114 // be generated (which cost is estimated separately).
115 TTI::PointersChainInfo PtrsInfo =
116 all_of(Ptrs,
117 [](const Value *V) {
118 auto *Ptr = dyn_cast<GetElementPtrInst>(V);
119 return Ptr && !Ptr->hasAllConstantIndices();
120 })
121 ? TTI::PointersChainInfo::getUnknownStride()
122 : TTI::PointersChainInfo::getKnownStride();
123
124 ScalarCost =
125 TTI.getPointersChainCost(Ptrs, BasePtr, PtrsInfo, ScalarTy, CostKind);
126 auto *BaseGEP = dyn_cast<GEPOperator>(BasePtr);
127 if (!BaseGEP) {
128 auto *It = find_if(Ptrs, IsaPred<GEPOperator>);
129 if (It != Ptrs.end())
130 BaseGEP = cast<GEPOperator>(*It);
131 }
132 if (BaseGEP) {
133 SmallVector<const Value *> Indices(BaseGEP->indices());
134 VecCost = TTI.getGEPCost(BaseGEP->getSourceElementType(),
135 BaseGEP->getPointerOperand(), Indices, CostKind,
136 VecTy);
137 }
138 }
139
140 return std::make_pair(ScalarCost, VecCost);
141}
142
144 Align Alignment, unsigned AddressSpace,
146 Type *CmpTy = CmpInst::makeCmpResultType(VecTy);
147 return 2 * TTI.getMemIntrinsicInstrCost(
148 MemIntrinsicCostAttributes(Intrinsic::masked_load, VecTy,
149 Alignment, AddressSpace),
150 CostKind) +
151 TTI.getArithmeticInstrCost(Instruction::Xor, CmpTy, CostKind) +
152 TTI.getCmpSelInstrCost(Instruction::Select, VecTy, CmpTy,
154}
155
157 unsigned Opcode, Type *ScalarTy,
158 unsigned NumElts,
160 FixedVectorType **PaddedTy) {
161 FixedVectorType *PaddedVecTy =
162 getMaskedDivRemType(TTI, Opcode, ScalarTy, NumElts, ReVec);
163 if (!PaddedVecTy)
165 // One mask bit per element of the padded vector, not per padded lane.
166 auto *MaskTy =
168 PaddedVecTy->getNumElements());
169 InstructionCost DirectCost = TTI.getArithmeticInstrCost(
170 Opcode, getWidenedType(ScalarTy, NumElts), CostKind);
171 IntrinsicCostAttributes ICA(getMaskedDivRemIntrinsic(Opcode), PaddedVecTy,
172 {PaddedVecTy, PaddedVecTy, MaskTy});
173 InstructionCost MaskedCost = TTI.getIntrinsicInstrCost(ICA, CostKind);
174 if (!MaskedCost.isValid() || MaskedCost >= DirectCost)
176 if (PaddedTy)
177 *PaddedTy = PaddedVecTy;
178 return MaskedCost;
179}
180
183 Type *ScalarTy, VectorType *Ty,
184 const APInt &DemandedElts, bool Insert, bool Extract,
185 const TTI::TargetCostKind CostKind, bool ForPoisonSrc,
188 "ScalableVectorType is not supported.");
189 assert(getNumElements(ScalarTy) * DemandedElts.getBitWidth() ==
190 getNumElements(Ty) &&
191 "Incorrect usage.");
192 if (auto *VecTy = dyn_cast<FixedVectorType>(ScalarTy)) {
193 assert(ReVec && "Only supported by REVEC.");
194 // If ScalarTy is FixedVectorType, we should use CreateInsertVector instead
195 // of CreateInsertElement.
196 unsigned ScalarTyNumElements = VecTy->getNumElements();
198 for (unsigned I : seq(DemandedElts.getBitWidth())) {
199 if (!DemandedElts[I])
200 continue;
201 if (Insert)
203 I * ScalarTyNumElements, VecTy);
204 if (Extract)
206 I * ScalarTyNumElements, VecTy);
207 }
208 return Cost;
209 }
210 return TTI.getScalarizationOverhead(Ty, DemandedElts, Insert, Extract,
211 CostKind, ForPoisonSrc, VL, VIC);
212}
213
215 const TargetTransformInfo &TTI, bool ReVec, Type *ScalarTy, unsigned Opcode,
216 Type *Val, const TTI::TargetCostKind CostKind, unsigned Index,
217 Value *Scalar,
218 ArrayRef<std::tuple<Value *, User *, int>> ScalarUserAndIdx) {
219 if (Opcode == Instruction::ExtractElement) {
220 if (auto *VecTy = dyn_cast<FixedVectorType>(ScalarTy)) {
221 assert(ReVec && "Only supported by REVEC.");
222 assert(isa<VectorType>(Val) && "Val must be a vector type.");
224 cast<VectorType>(Val), CostKind, {},
225 Index * VecTy->getNumElements(), VecTy);
226 }
227 }
228 return TTI.getVectorInstrCost(Opcode, Val, CostKind, Index, Scalar,
229 ScalarUserAndIdx);
230}
231
233 bool ReVec, unsigned Opcode, Type *Dst,
234 VectorType *VecTy, unsigned Index,
236 if (isVectorizedTy(Dst)) {
237 assert(ReVec && "Only supported by REVEC.");
238 auto *SubTp = cast<FixedVectorType>(
241 Index * getNumElements(Dst), SubTp) +
242 TTI.getCastInstrCost(Opcode, Dst, SubTp, TTI::CastContextHint::None,
243 CostKind);
244 }
245 return TTI.getExtractWithExtendCost(Opcode, Dst, VecTy, Index, CostKind);
246}
247
248/// Returns the cast context hint for the trunc of the booleanized reduction
249/// result, which inherits the uses of the reduction root \p Root.
262
264 RecurKind RdxKind,
265 FixedVectorType *VecTy,
266 const Value *Root, FastMathFlags FMF,
268 Type *I1Ty = Type::getInt1Ty(VecTy->getContext());
269 return TTI.getArithmeticReductionCost(
270 RecurrenceDescriptor::getOpcode(RdxKind), VecTy, FMF, CostKind) +
271 TTI.getCastInstrCost(Instruction::Trunc, I1Ty, VecTy->getScalarType(),
273}
274
276 RecurKind RdxKind,
277 FixedVectorType *VecTy,
278 const Value *Root,
279 ArrayRef<Instruction *> ChainInsts,
281 // The new instructions are costed in the context of the replaced cast chain
282 // instructions.
283 auto TruncIt =
284 find_if(ChainInsts, [](Instruction *I) { return isa<TruncInst>(I); });
285 const Instruction *TruncI = TruncIt == ChainInsts.end() ? nullptr : *TruncIt;
286 auto CmpIt =
287 find_if(ChainInsts, [](Instruction *I) { return isa<ICmpInst>(I); });
288 const Instruction *CmpI = CmpIt == ChainInsts.end() ? nullptr : *CmpIt;
289 unsigned VF = VecTy->getNumElements();
290 auto *I1VecTy =
292 Type *IntTy = IntegerType::get(VecTy->getContext(), VF);
293 Constant *CmpRHS = RdxKind == RecurKind::And
295 : Constant::getNullValue(IntTy);
296 return TTI.getCastInstrCost(Instruction::Trunc, I1VecTy, VecTy,
297 TTI.getCastContextHint(TruncI), CostKind,
298 TruncI) +
299 TTI.getCastInstrCost(Instruction::BitCast, IntTy, I1VecTy,
300 TTI.getCastContextHint(TruncI), CostKind) +
301 TTI.getCmpSelInstrCost(Instruction::ICmp, IntTy, /*CondTy=*/nullptr,
304 CostKind, TTI.getOperandInfo(Root),
305 TTI.getOperandInfo(CmpRHS), CmpI);
306}
307
309 FixedVectorType *SrcTy, Type *ResultTy,
310 const BitPackInfo &Info, unsigned ZExtSrcWidth,
313 const TargetLibraryInfo *TLI,
314 const Instruction *CxtI, unsigned &ShiftWidth) {
315 unsigned BitWidth = SrcTy->getScalarSizeInBits();
316 unsigned NumElts = SrcTy->getNumElements();
317 uint64_t MaxAmt = *max_element(Info.LShrAmts);
318 // The shift amounts form a constant vector.
319 TTI::OperandValueInfo ShiftAmtInfo = {
322 all_of(Info.LShrAmts,
323 [](uint64_t A) { return A == 0 || isPowerOf2_64(A); })
325 : TTI::OP_None};
326 // After the shift the field content of each lane sits in the low bits of
327 // the lane, so the packing is a single byte shuffle of the shifted lanes.
328 // Pick the cheapest shift width: the narrowest type still holding the field
329 // content is not always the cheapest (e.g. missing narrow variable shifts).
330 Type *Int8Ty = Type::getInt8Ty(SrcTy->getContext());
331 assert(BitWidth % 8 == 0 &&
332 "The byte-multiple field width divides the result bit width.");
333 unsigned OutBytes = BitWidth / 8;
334 auto *PackTy = FixedVectorType::get(Int8Ty, OutBytes);
335 unsigned MinShiftWidth = 8;
336 while (MinShiftWidth < MaxAmt + Info.FieldWidth)
337 MinShiftWidth *= 2;
339 ShiftWidth = 0;
340 for (unsigned W2 = MinShiftWidth; W2 <= BitWidth; W2 *= 2) {
341 auto *ShiftTy = FixedVectorType::get(
342 IntegerType::get(SrcTy->getContext(), W2), NumElts);
343 unsigned BytesPerLane = W2 / 8;
344 unsigned InBytes = NumElts * BytesPerLane;
345 SmallVector<int> Mask =
346 getBitPackMask(Info, OutBytes, NumElts, BytesPerLane);
347 InstructionCost C = TTI.getCastInstrCost(Instruction::BitCast, ResultTy,
348 PackTy, CCH, CostKind);
349 // A plain byte reversal of the shifted lanes is a bswap, no shuffle.
350 if (ShuffleVectorInst::isReverseMask(Mask, InBytes)) {
351 IntrinsicCostAttributes CostAttrs(Intrinsic::bswap, ResultTy, {ResultTy});
352 C += TTI.getIntrinsicInstrCost(CostAttrs, CostKind);
353 } else if (!ShuffleVectorInst::isIdentityMask(Mask, InBytes)) {
354 C += TTI.getShuffleCost(
355 is_contained(Info.LaneOfField, BitPackInfo::NoLane)
358 PackTy, FixedVectorType::get(Int8Ty, InBytes), CostKind, Mask,
359 /*Index=*/0, /*SubTp=*/nullptr, /*Args=*/{}, CxtI);
360 }
361 if (W2 != BitWidth && W2 != ZExtSrcWidth)
362 C += TTI.getCastInstrCost(Instruction::Trunc, ShiftTy, SrcTy, CCH,
363 CostKind);
364 if (Info.needsShift())
365 C += TTI.getArithmeticInstrCost(Instruction::LShr, ShiftTy, CostKind,
366 /*Opd1Info=*/{}, ShiftAmtInfo,
367 /*Args=*/{}, CxtI, TLI);
368 if (C.isValid() && (!NewCost.isValid() || C < NewCost)) {
369 NewCost = C;
370 ShiftWidth = W2;
371 }
372 }
373 return NewCost;
374}
375
376} // namespace llvm::slpvectorizer
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file implements a class to represent arbitrary precision integral constant values and operations...
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
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")))
#define I(x, y, z)
Definition MD5.cpp:57
This file contains some templates that are useful if you are working with the STL at all.
Provides some synthesis utilities to produce sequences of values.
This file defines the SmallVector class.
Class for arbitrary precision integers.
Definition APInt.h:78
unsigned getBitWidth() const
Return the number of bits in the APInt.
Definition APInt.h:1508
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
iterator end() const
Definition ArrayRef.h:130
static Type * makeCmpResultType(Type *opnd_type)
Create a result type for fcmp/icmp.
@ ICMP_NE
not equal
Definition InstrTypes.h:762
This is an important base class in LLVM.
Definition Constant.h:43
static LLVM_ABI Constant * getAllOnesValue(Type *Ty)
static LLVM_ABI Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
Convenience struct for specifying and reasoning about fast-math flags.
Definition FMF.h:23
Class to represent fixed width SIMD vectors.
unsigned getNumElements() const
static LLVM_ABI FixedVectorType * get(Type *ElementType, unsigned NumElts)
Definition Type.cpp:843
static InstructionCost getInvalid(CostType Val=0)
static LLVM_ABI IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
Definition Type.cpp:338
Information for memory intrinsic cost model.
static LLVM_ABI unsigned getOpcode(RecurKind Kind)
Returns the opcode corresponding to the RecurrenceKind.
static LLVM_ABI bool isIdentityMask(ArrayRef< int > Mask, int NumSrcElts)
Return true if this shuffle mask chooses elements from exactly one source vector without lane crossin...
static LLVM_ABI bool isReverseMask(ArrayRef< int > Mask, int NumSrcElts)
Return true if this shuffle mask swaps the order of elements from exactly one source vector.
static LLVM_ABI bool isInsertSubvectorMask(ArrayRef< int > Mask, int NumSrcElts, int &NumSubElts, int &Index)
Return true if this shuffle mask is an insert subvector mask.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
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.
llvm::VectorInstrContext VectorInstrContext
@ TCC_Free
Expected to fold away in lowering.
ShuffleKind
The various kinds of shuffle patterns for vector queries.
@ SK_InsertSubvector
InsertSubvector. Index indicates start offset.
@ SK_PermuteSingleSrc
Shuffle elements of single source vector with any shuffle mask.
@ SK_PermuteTwoSrc
Merge elements from two source vectors into one with any shuffle mask.
@ SK_ExtractSubvector
ExtractSubvector Index indicates start offset.
CastContextHint
Represents a hint about the context in which a cast is used.
@ Masked
The cast is used with a masked load/store.
@ None
The cast is not used with a load/store of any kind.
@ Normal
The cast is used with a normal load/store.
@ GatherScatter
The cast is used with a gather/scatter.
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
static LLVM_ABI IntegerType * getInt8Ty(LLVMContext &C)
Definition Type.cpp:297
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
Definition Type.h:363
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
Definition Type.h:130
static LLVM_ABI IntegerType * getInt1Ty(LLVMContext &C)
Definition Type.cpp:296
LLVM Value Representation.
Definition Value.h:75
user_iterator user_begin()
Definition Value.h:404
bool hasOneUse() const
Return true if there is exactly one use of this value.
Definition Value.h:441
Base class of all SIMD vector types.
ElementCount getElementCount() const
Return an ElementCount instance to represent the (possibly scalable) number of elements in the vector...
constexpr ScalarTy getKnownMinValue() const
Returns the minimum value this quantity can represent.
Definition TypeSize.h:165
bool match(Val *V, const Pattern &P)
auto m_Intrinsic(const Ts &...Ops)
Match intrinsic calls like this: m_Intrinsic<Intrinsic::fabs>(m_Value(X))
A private "module" namespace for types and utilities used by this pass.
InstructionCost getBitPackCost(const TargetTransformInfo &TTI, FixedVectorType *SrcTy, Type *ResultTy, const BitPackInfo &Info, unsigned ZExtSrcWidth, TTI::CastContextHint CCH, TTI::TargetCostKind CostKind, const TargetLibraryInfo *TLI, const Instruction *CxtI, unsigned &ShiftWidth)
Returns the cost of the bitfield packing of SrcTy into ResultTy, picking the cheapest shift width.
InstructionCost getBoolReduxBitcastCmpCost(const TargetTransformInfo &TTI, RecurKind RdxKind, FixedVectorType *VecTy, const Value *Root, ArrayRef< Instruction * > ChainInsts, const TTI::TargetCostKind CostKind)
Returns the cost of the booleanized logical and/or reduction of a vector of type VecTy with the i1 ro...
std::pair< InstructionCost, InstructionCost > getGEPCosts(const TargetTransformInfo &TTI, ArrayRef< Value * > Ptrs, Value *BasePtr, unsigned Opcode, const TTI::TargetCostKind CostKind, Type *ScalarTy, VectorType *VecTy)
Calculate the scalar and the vector costs from vectorizing set of GEPs.
Intrinsic::ID getMaskedDivRemIntrinsic(unsigned Opcode)
Definition SLPUtils.cpp:937
SmallVector< int > getBitPackMask(const BitPackInfo &Info, unsigned NumBytes, unsigned NumElts, unsigned BytesPerLane)
Returns the byte shuffle mask packing the per-lane fields of the shifted lanes (BytesPerLane bytes ea...
unsigned getNumElements(Type *Ty)
Definition SLPUtils.cpp:86
Type * getWidenedType(Type *ScalarTy, unsigned VF)
InstructionCost getShuffleCost(const TargetTransformInfo &TTI, TTI::ShuffleKind Kind, VectorType *Tp, const TTI::TargetCostKind CostKind, ArrayRef< int > Mask, int Index, VectorType *SubTp, ArrayRef< const Value * > Args)
Returns the cost of the shuffle instructions with the given Kind, vector type Tp and optional Mask.
static TTI::CastContextHint getBoolReduxResultCCH(const Value *Root)
Returns the cast context hint for the trunc of the booleanized reduction result, which inherits the u...
InstructionCost getBlendedLoadCost(const TargetTransformInfo &TTI, Type *VecTy, Align Alignment, unsigned AddressSpace, const TTI::TargetCostKind CostKind)
Returns the cost of a BlendedLoadVectorize node loading VecTy: two masked loads (one per candidate ba...
FixedVectorType * getMaskedDivRemType(const TargetTransformInfo &TTI, unsigned Opcode, Type *ScalarTy, unsigned NumElts, bool ReVec)
For a non-power-of-2 NumElts-wide integer div/rem Opcode, returns the padded full-register vector typ...
InstructionCost getVectorInstrCost(const TargetTransformInfo &TTI, bool ReVec, Type *ScalarTy, unsigned Opcode, Type *Val, const TTI::TargetCostKind CostKind, unsigned Index, Value *Scalar, ArrayRef< std::tuple< Value *, User *, int > > ScalarUserAndIdx)
This is similar to TargetTransformInfo::getVectorInstrCost, but if ScalarTy is a FixedVectorType,...
InstructionCost getBoolReduxWideRdxCost(const TargetTransformInfo &TTI, RecurKind RdxKind, FixedVectorType *VecTy, const Value *Root, FastMathFlags FMF, const TTI::TargetCostKind CostKind)
Returns the cost of the booleanized logical and/or reduction of a vector of type VecTy with the i1 ro...
InstructionCost getScalarizationOverhead(const TargetTransformInfo &TTI, bool ReVec, Type *ScalarTy, VectorType *Ty, const APInt &DemandedElts, bool Insert, bool Extract, const TTI::TargetCostKind CostKind, bool ForPoisonSrc, ArrayRef< Value * > VL, TTI::VectorInstrContext VIC)
This is similar to TargetTransformInfo::getScalarizationOverhead, but if ScalarTy is a FixedVectorTyp...
InstructionCost getExtractWithExtendCost(const TargetTransformInfo &TTI, bool ReVec, unsigned Opcode, Type *Dst, VectorType *VecTy, unsigned Index, const TTI::TargetCostKind CostKind)
This is similar to TargetTransformInfo::getExtractWithExtendCost, but if Dst is a FixedVectorType,...
InstructionCost getMaskedDivRemCost(const TargetTransformInfo &TTI, bool ReVec, unsigned Opcode, Type *ScalarTy, unsigned NumElts, const TTI::TargetCostKind CostKind, FixedVectorType **PaddedTy)
For a non-power-of-2 NumElts-wide integer div/rem Opcode, checks if padding to a full register and us...
This is an optimization pass for GlobalISel generic memory operations.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1755
InstructionCost Cost
Type * toScalarizedTy(Type *Ty)
A helper for converting vectorized types to scalarized (non-vector) types.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
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...
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
Definition Casting.h:547
TargetTransformInfo TTI
RecurKind
These are the kinds of recurrences that we support.
@ And
Bitwise or logical AND of integers.
auto max_element(R &&Range)
Provide wrappers to std::max_element which take ranges instead of having to pass begin/end explicitly...
Definition STLExtras.h:2104
constexpr unsigned BitWidth
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1788
constexpr auto seq(T Begin, T End)
Iterate over an integral type from Begin up to - but not including - End.
Definition Sequence.h:341
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
Definition STLExtras.h:1963
bool all_equal(std::initializer_list< T > Values)
Returns true if all Values in the initializer lists are equal or the list.
Definition STLExtras.h:2182
constexpr detail::IsaCheckPredicate< Types... > IsaPred
Function object wrapper for the llvm::isa type check.
Definition Casting.h:866
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition Alignment.h:39
Describe known properties for a set of pointers.
Description of a bitfield packing of vector lanes into a scalar value: every lane contributes a disjo...
Definition SLPUtils.h:424
static constexpr unsigned NoLane
Definition SLPUtils.h:425