29 #define DEBUG_TYPE "vectorutils" 37 cl::desc(
"Maximum factor for an interleaved access group (default = 8)"),
46 case Intrinsic::bswap:
47 case Intrinsic::bitreverse:
48 case Intrinsic::ctpop:
53 case Intrinsic::sadd_sat:
54 case Intrinsic::ssub_sat:
55 case Intrinsic::uadd_sat:
56 case Intrinsic::usub_sat:
57 case Intrinsic::smul_fix:
58 case Intrinsic::smul_fix_sat:
59 case Intrinsic::umul_fix:
60 case Intrinsic::umul_fix_sat:
67 case Intrinsic::log10:
74 case Intrinsic::copysign:
75 case Intrinsic::floor:
77 case Intrinsic::trunc:
79 case Intrinsic::nearbyint:
83 case Intrinsic::fmuladd:
85 case Intrinsic::canonicalize:
94 unsigned ScalarOpdIdx) {
99 return (ScalarOpdIdx == 1);
100 case Intrinsic::smul_fix:
101 case Intrinsic::smul_fix_sat:
102 case Intrinsic::umul_fix:
103 case Intrinsic::umul_fix_sat:
104 return (ScalarOpdIdx == 2);
120 ID == Intrinsic::lifetime_end || ID == Intrinsic::assume ||
121 ID == Intrinsic::sideeffect)
138 std::advance(GEPTI, LastOperand - 2);
163 if (i != InductionOperand &&
171 Value *UniqueCast =
nullptr;
174 if (CI && CI->
getType() == Ty) {
188 if (!PtrTy || PtrTy->isAggregateType())
194 Value *OrigPtr = Ptr;
197 int64_t PtrAccessSize = 1;
217 if (OrigPtr == Ptr) {
218 if (
const SCEVMulExpr *M = dyn_cast<SCEVMulExpr>(V)) {
219 if (M->getOperand(0)->getSCEVType() !=
scConstant)
222 const APInt &APStepVal = cast<SCEVConstant>(M->getOperand(0))->getAPInt();
229 if (PtrAccessSize != StepVal)
231 V = M->getOperand(1);
236 Type *StripedOffRecurrenceCast =
nullptr;
238 StripedOffRecurrenceCast =
C->
getType();
253 if (StripedOffRecurrenceCast)
265 unsigned Width = VTy->getNumElements();
270 return C->getAggregateElement(EltNo);
274 if (!isa<ConstantInt>(III->getOperand(2)))
276 unsigned IIElt = cast<ConstantInt>(III->getOperand(2))->getZExtValue();
281 return III->getOperand(1);
290 int InEl = SVI->getMaskValue(EltNo);
293 if (InEl < (
int)LHSWidth)
303 if (Elt->isNullValue())
315 if (isa<VectorType>(V->
getType()))
316 if (
auto *
C = dyn_cast<Constant>(V))
317 return C->getSplatValue();
334 assert(Depth <= MaxDepth &&
"Limit Search Depth");
336 if (isa<VectorType>(V->
getType())) {
337 if (isa<UndefValue>(V))
340 if (
auto *
C = dyn_cast<Constant>(V))
341 return C->getSplatValue() !=
nullptr;
350 if (Depth++ == MaxDepth)
384 bool SeenExtFromIllegalType =
false;
385 for (
auto *BB : Blocks)
386 for (
auto &
I : *BB) {
389 if (TTI && (isa<ZExtInst>(&
I) || isa<SExtInst>(&
I)) &&
391 SeenExtFromIllegalType =
true;
394 if ((isa<TruncInst>(&
I) || isa<ICmpInst>(&
I)) &&
395 !
I.getType()->isVectorTy() &&
396 I.getOperand(0)->getType()->getScalarSizeInBits() <= 64) {
399 if (TTI && isa<TruncInst>(&
I) && TTI->
isTypeLegal(
I.getType()))
407 if (Worklist.
empty() || (TTI && !SeenExtFromIllegalType))
411 while (!Worklist.
empty()) {
415 if (Visited.
count(Val))
420 if (!isa<Instruction>(Val))
435 if (isa<SExtInst>(I) || isa<ZExtInst>(I) || isa<LoadInst>(I) ||
436 !InstructionSet.
count(I))
442 if (isa<BitCastInst>(I) || isa<PtrToIntInst>(
I) || isa<IntToPtrInst>(I) ||
444 DBits[Leader] |= ~0ULL;
454 if (DBits[Leader] == ~0ULL)
458 for (
Value *
O : cast<User>(I)->operands()) {
467 for (
auto &
I : DBits)
468 for (
auto *U :
I.first->users())
469 if (U->getType()->isIntegerTy() && DBits.count(U) == 0)
473 uint64_t LeaderDemandedBits = 0;
475 LeaderDemandedBits |= DBits[*
MI];
477 uint64_t MinBW = (
sizeof(LeaderDemandedBits) * 8) -
489 if (isa<PHINode>(*
MI) && MinBW < (*MI)->getType()->getScalarSizeInBits()) {
497 if (!isa<Instruction>(*
MI))
499 Type *Ty = (*MI)->getType();
501 Ty = cast<Instruction>(*MI)->getOperand(0)->getType();
503 MinBWs[cast<Instruction>(*MI)] = MinBW;
511 template <
typename ListT>
516 List.insert(AccGroups);
520 for (
auto &AccGroupListOp : AccGroups->
operands()) {
521 auto *Item = cast<MDNode>(AccGroupListOp.get());
532 if (AccGroups1 == AccGroups2)
539 if (Union.
size() == 0)
541 if (Union.
size() == 1)
542 return cast<MDNode>(Union.
front());
553 if (!MayAccessMem1 && !MayAccessMem2)
556 return Inst2->
getMetadata(LLVMContext::MD_access_group);
558 return Inst1->
getMetadata(LLVMContext::MD_access_group);
574 if (AccGroupSet2.
count(MD1))
578 auto *Item = cast<MDNode>(Node.get());
580 if (AccGroupSet2.
count(Item))
585 if (Intersection.
size() == 0)
587 if (Intersection.
size() == 1)
588 return cast<MDNode>(Intersection.
front());
600 for (
auto Kind : {LLVMContext::MD_tbaa, LLVMContext::MD_alias_scope,
601 LLVMContext::MD_noalias, LLVMContext::MD_fpmath,
602 LLVMContext::MD_nontemporal, LLVMContext::MD_invariant_load,
603 LLVMContext::MD_access_group}) {
606 for (
int J = 1,
E = VL.
size(); MD && J !=
E; ++J) {
610 case LLVMContext::MD_tbaa:
613 case LLVMContext::MD_alias_scope:
616 case LLVMContext::MD_fpmath:
619 case LLVMContext::MD_noalias:
620 case LLVMContext::MD_nontemporal:
621 case LLVMContext::MD_invariant_load:
624 case LLVMContext::MD_access_group:
649 for (
unsigned i = 0; i < VF; i++)
650 for (
unsigned j = 0; j < Group.
getFactor(); ++j) {
651 unsigned HasMember = Group.
getMember(j) ? 1 : 0;
652 Mask.push_back(Builder.
getInt1(HasMember));
659 unsigned ReplicationFactor,
unsigned VF) {
661 for (
unsigned i = 0; i < VF; i++)
662 for (
unsigned j = 0; j < ReplicationFactor; j++)
671 for (
unsigned i = 0; i < VF; i++)
672 for (
unsigned j = 0; j < NumVecs; j++)
679 unsigned Stride,
unsigned VF) {
681 for (
unsigned i = 0; i < VF; i++)
688 unsigned NumInts,
unsigned NumUndefs) {
690 for (
unsigned i = 0; i < NumInts; i++)
694 for (
unsigned i = 0; i < NumUndefs; i++)
707 assert(VecTy1 && VecTy2 &&
709 "Expect two vectors with the same element type");
712 unsigned NumElts2 = VecTy2->getNumElements();
713 assert(NumElts1 >= NumElts2 &&
"Unexpect the first vector has less elements");
715 if (NumElts1 > NumElts2) {
727 unsigned NumVecs = Vecs.
size();
728 assert(NumVecs > 1 &&
"Should be at least two vectors");
734 for (
unsigned i = 0; i < NumVecs - 1; i += 2) {
735 Value *V0 = ResList[i], *V1 = ResList[i + 1];
736 assert((V0->
getType() == V1->getType() || i == NumVecs - 2) &&
737 "Only the last vector may have a different type");
743 if (NumVecs % 2 != 0)
747 NumVecs = ResList.
size();
748 }
while (NumVecs > 1);
757 if (ConstMask->isNullValue() || isa<UndefValue>(ConstMask))
759 for (
unsigned I = 0,
E = ConstMask->getType()->getVectorNumElements();
I !=
E;
761 if (
auto *MaskElt = ConstMask->getAggregateElement(
I))
762 if (MaskElt->isNullValue() || isa<UndefValue>(MaskElt))
774 if (ConstMask->isAllOnesValue() || isa<UndefValue>(ConstMask))
776 for (
unsigned I = 0,
E = ConstMask->getType()->getVectorNumElements();
I !=
E;
778 if (
auto *MaskElt = ConstMask->getAggregateElement(
I))
779 if (MaskElt->isAllOnesValue() || isa<UndefValue>(MaskElt))
790 const unsigned VWidth = cast<VectorType>(Mask->
getType())->getNumElements();
792 if (
auto *CV = dyn_cast<ConstantVector>(Mask))
793 for (
unsigned i = 0; i < VWidth; i++)
794 if (CV->getAggregateElement(i)->isNullValue())
799 bool InterleavedAccessInfo::isStrided(
int Stride) {
804 void InterleavedAccessInfo::collectConstStrideAccesses(
807 auto &DL = TheLoop->getHeader()->getModule()->getDataLayout();
818 for (
auto &
I : *BB) {
832 int64_t Stride =
getPtrStride(PSE, Ptr, TheLoop, Strides,
844 AccessStrideInfo[&
I] = StrideDescriptor(Stride, Scev, Size, *Alignment);
885 bool EnablePredicatedInterleavedMemAccesses) {
891 collectConstStrideAccesses(AccessStrideInfo, Strides);
893 if (AccessStrideInfo.
empty())
897 collectDependences();
916 for (
auto BI = AccessStrideInfo.
rbegin(),
E = AccessStrideInfo.
rend();
919 StrideDescriptor DesB = BI->second;
925 if (isStrided(DesB.Stride) &&
927 Group = getInterleaveGroup(B);
929 LLVM_DEBUG(
dbgs() <<
"LV: Creating an interleave group with:" << *B
931 Group = createInterleaveGroup(B, DesB.Stride, DesB.Alignment);
934 StoreGroups.
insert(Group);
939 for (
auto AI = std::next(BI); AI !=
E; ++AI) {
941 StrideDescriptor DesA = AI->second;
962 if (!canReorderMemAccessesForInterleavedGroups(&*AI, &*BI)) {
968 if (isInterleaved(A)) {
972 "dependence between " << *A <<
" and "<< *B <<
'\n');
974 StoreGroups.
remove(StoreGroup);
975 releaseGroup(StoreGroup);
988 if (!isStrided(DesA.Stride) || !isStrided(DesB.Stride))
997 if (isInterleaved(A) ||
1004 if (DesA.Stride != DesB.Stride || DesA.Size != DesB.Size)
1014 PSE.getSE()->getMinusSCEV(DesA.Scev, DesB.Scev));
1021 if (DistanceToB % static_cast<int64_t>(DesB.Size))
1029 (!EnablePredicatedInterleavedMemAccesses || BlockA != BlockB))
1035 Group->
getIndex(B) + DistanceToB /
static_cast<int64_t
>(DesB.Size);
1040 <<
" into the interleave group with" << *B
1042 InterleaveGroupMap[A] = Group;
1052 for (
auto *Group : StoreGroups)
1053 if (Group->getNumMembers() != Group->getFactor()) {
1055 dbgs() <<
"LV: Invalidate candidate interleaved store group due " 1057 releaseGroup(Group);
1073 for (
auto *Group : LoadGroups) {
1077 if (Group->getNumMembers() == Group->getFactor())
1086 if (!
getPtrStride(PSE, FirstMemberPtr, TheLoop, Strides,
false,
1089 dbgs() <<
"LV: Invalidate candidate interleaved group due to " 1090 "first group member potentially pointer-wrapping.\n");
1091 releaseGroup(Group);
1094 Instruction *LastMember = Group->getMember(Group->getFactor() - 1);
1097 if (!
getPtrStride(PSE, LastMemberPtr, TheLoop, Strides,
false,
1100 dbgs() <<
"LV: Invalidate candidate interleaved group due to " 1101 "last group member potentially pointer-wrapping.\n");
1102 releaseGroup(Group);
1110 if (Group->isReverse()) {
1112 dbgs() <<
"LV: Invalidate candidate interleaved group due to " 1113 "a reverse access with gaps.\n");
1114 releaseGroup(Group);
1118 dbgs() <<
"LV: Interleaved group requires epilogue iteration.\n");
1119 RequiresScalarEpilogue =
true;
1127 if (!requiresScalarEpilogue())
1132 for (
auto &
I : InterleaveGroupMap) {
1137 for (
auto *Ptr : DelSet) {
1140 <<
"LV: Invalidate candidate interleaved group due to gaps that " 1141 "require a scalar epilogue (not allowed under optsize) and cannot " 1142 "be masked (not enabled). \n");
1146 RequiresScalarEpilogue =
false;
1149 template <
typename InstT>
1158 std::transform(Members.begin(), Members.end(), std::back_inserter(VL),
1159 [](std::pair<int, Instruction *> p) {
return p.second; });
1173 S.
split(ListAttr,
",");
1180 "Vector function is missing.");
1187 for (
unsigned Pos = 0, NumParams = Parameters.size(); Pos < NumParams;
1189 assert(Parameters[Pos].ParamPos == Pos &&
"Broken parameter list.");
1191 switch (Parameters[Pos].ParamKind) {
1199 if (Parameters[Pos].LinearStepOrPos == 0)
1208 if (Parameters[Pos].LinearStepOrPos >=
int(NumParams))
1211 if (Parameters[Parameters[Pos].LinearStepOrPos].ParamKind !=
1215 if (Parameters[Pos].LinearStepOrPos ==
int(Pos))
1221 for (
unsigned NextPos = Pos + 1; NextPos < NumParams; ++NextPos)
void getAllMetadataOtherThanDebugLoc(SmallVectorImpl< std::pair< unsigned, MDNode *>> &MDs) const
This does the same thing as getAllMetadata, except that it filters out the debug location.
Value * getStrideFromPointer(Value *Ptr, ScalarEvolution *SE, Loop *Lp)
Get the stride of a pointer access in a loop.
bool hasValidParameterList() const
Sanity check on the Parameters in the VFShape.
Value * stripGetElementPtr(Value *Ptr, ScalarEvolution *SE, Loop *Lp)
If the argument is a GEP, then returns the operand identified by getGEPInductionOperand.
A parsed version of the target data layout string in and methods for querying it. ...
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
Tracking metadata reference owned by Metadata.
class_match< Value > m_Value()
Match an arbitrary value and ignore it.
void setInsertPos(InstTy *Inst)
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
uint64_t getZExtValue() const
Get zero extended value.
ThreeOps_match< Cond, LHS, RHS, Instruction::Select > m_Select(const Cond &C, const LHS &L, const RHS &R)
Matches SelectInst.
static APInt getAllOnesValue(unsigned numBits)
Get the all-ones value.
MapVector< Instruction *, uint64_t > computeMinimumValueSizes(ArrayRef< BasicBlock *> Blocks, DemandedBits &DB, const TargetTransformInfo *TTI=nullptr)
Compute a map of integer instructions to their minimum legal type size.
is_zero m_Zero()
Match any null constant or a vector with all elements equal to 0.
void getVectorVariantNames(const CallInst &CI, SmallVectorImpl< std::string > &VariantMappings)
Populates a set of strings representing the Vector Function ABI variants associated to the CallInst C...
Value * findScalarElement(Value *V, unsigned EltNo)
Given a vector and an element number, see if the scalar value is already around as a register...
const T & front() const
Return the first element of the SetVector.
This class represents lattice values for constants.
ArrayRef< T > getArrayRef() const
size_type size() const
Determine the number of elements in the SetVector.
const Value * getSplatValue(const Value *V)
Get splat value if the input is a splat vector or return nullptr.
void push_back(const T &Elt)
Instruction * propagateMetadata(Instruction *I, ArrayRef< Value *> VL)
Specifically, let Kinds = [MD_tbaa, MD_alias_scope, MD_noalias, MD_fpmath, MD_nontemporal, MD_access_group].
The main scalar evolution driver.
static MDNode * getMostGenericAliasScope(MDNode *A, MDNode *B)
This class represents a function call, abstracting a target machine's calling convention.
int64_t getPtrStride(PredicatedScalarEvolution &PSE, Value *Ptr, const Loop *Lp, const ValueToValueMap &StridesMap=ValueToValueMap(), bool Assume=false, bool ShouldCheckWrap=true)
If the pointer has a constant stride return it in units of its element size.
ThreeOps_match< Val_t, Elt_t, Idx_t, Instruction::InsertElement > m_InsertElement(const Val_t &Val, const Elt_t &Elt, const Idx_t &Idx)
Matches InsertElementInst.
class_match< Constant > m_Constant()
Match an arbitrary Constant and ignore it.
static uint64_t round(uint64_t Acc, uint64_t Input)
bool mayWriteToMemory() const
Return true if this instruction may modify memory.
This instruction constructs a fixed permutation of two input vectors.
LLVMContext & getContext() const
All values hold a context through their type.
This class implements a map that also provides access to all stored values in a deterministic order...
bool isLoopInvariant(const SCEV *S, const Loop *L)
Return true if the value of the given SCEV is unchanging in the specified loop.
ThreeOps_match< V1_t, V2_t, Mask_t, Instruction::ShuffleVector > m_ShuffleVector(const V1_t &v1, const V2_t &v2, const Mask_t &m)
Matches ShuffleVectorInst.
An instruction for reading from memory.
member_iterator unionSets(const ElemTy &V1, const ElemTy &V2)
union - Merge the two equivalence sets for the specified values, inserting them if they do not alread...
bool isVectorTy() const
True if this is an instance of VectorType.
LLVM_READONLY APFloat maximum(const APFloat &A, const APFloat &B)
Implements IEEE 754-2018 maximum semantics.
cst_pred_ty< is_zero_int > m_ZeroInt()
Match an integer 0 or a vector with all elements equal to 0.
This is the base class for unary cast operator classes.
unsigned getBitWidth() const
Return the number of bits in the APInt.
bool insertMember(InstTy *Instr, int32_t Index, Align NewAlign)
Try to insert a new member Instr with index Index and alignment NewAlign.
Intrinsic::ID getVectorIntrinsicIDForCall(const CallInst *CI, const TargetLibraryInfo *TLI)
Returns intrinsic ID for call.
Intrinsic::ID getIntrinsicForCallSite(ImmutableCallSite ICS, const TargetLibraryInfo *TLI)
Map a call instruction to an intrinsic ID.
static cl::opt< unsigned > MaxInterleaveGroupFactor("max-interleave-group-factor", cl::Hidden, cl::desc("Maximum factor for an interleaved access group (default = 8)"), cl::init(8))
Maximum factor for an interleaved memory access.
IntegerType * getInt32Ty()
Fetch the type representing a 32-bit integer.
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
bool match(Val *V, const Pattern &P)
const Value * getLoadStorePointerOperand(const Value *V)
A helper function that returns the pointer operand of a load or store instruction.
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
This is the base class for all instructions that perform data casts.
static Value * concatenateTwoVectors(IRBuilder<> &Builder, Value *V1, Value *V2)
A helper function for concatenating vectors.
bool isIntegerTy() const
True if this is an instance of IntegerType.
LLVM_READONLY APFloat minimum(const APFloat &A, const APFloat &B)
Implements IEEE 754-2018 minimum semantics.
RPOIterator endRPO() const
uint64_t getNumElements() const
For scalable vectors, this will return the minimum number of elements in the vector.
bool remove(const value_type &X)
Remove an item from the set vector.
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
This node represents multiplication of some number of SCEVs.
BinaryOp_match< LHS, RHS, Instruction::Add > m_Add(const LHS &L, const RHS &R)
const APInt & getAPInt() const
int64_t getSExtValue() const
Get sign extended value.
Constant * createSequentialMask(IRBuilder<> &Builder, unsigned Start, unsigned NumInts, unsigned NumUndefs)
Create a sequential shuffle mask.
Type * getType() const
All values are typed, get the type of this value.
bool insert(const value_type &X)
Insert a new element into the SetVector.
member_iterator member_begin(iterator I) const
This node represents a polynomial recurrence on the trip count of the specified loop.
op_range operands() const
const T & getValue() const LLVM_LVALUE_FUNCTION
LLVMContext & getContext() const
void clearBit(unsigned BitPosition)
Set a given bit to 0.
static constexpr char const * MappingsAttrName
bool isSplatValue(const Value *V, unsigned Depth=0)
Return true if the input value is known to be a vector with all identical elements (potentially inclu...
The group of interleaved loads/stores sharing the same stride and close to each other.
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
bool maskIsAllOneOrUndef(Value *Mask)
Given a mask vector of the form <Y x="" i1>="">, Return true if all of the elements of this predicate...
static MDNode * intersect(MDNode *A, MDNode *B)
An instruction for storing to memory.
unsigned getLoadStoreAddressSpace(Value *I)
A helper function that returns the address space of the pointer operand of load or store instruction...
const SCEV * getStepRecurrence(ScalarEvolution &SE) const
Constructs and returns the recurrence indicating how much this expression steps by.
void perform(LoopInfo *LI)
Traverse the loop blocks and store the DFS result.
void invalidateGroupsRequiringScalarEpilogue()
Invalidate groups that require a scalar epilogue (due to gaps).
Value * getOperand(unsigned i) const
Analysis containing CSE Info
MDNode * intersectAccessGroups(const Instruction *Inst1, const Instruction *Inst2)
Compute the access-group list of access groups that Inst1 and Inst2 are both in.
InstTy * getMember(uint32_t Index) const
Get the member with the given index Index.
Class to represent pointers.
Constant * getAggregateElement(unsigned Elt) const
For aggregates (struct/array/vector) return the constant that corresponds to the specified element if...
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
Constant * getSplatValue(bool AllowUndefs=false) const
If all elements of the vector constant have the same value, return that value.
an instruction for type-safe pointer arithmetic to access elements of arrays and structs ...
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata *> MDs)
This means that we are dealing with an entirely unknown SCEV value, and only represent it as its LLVM...
initializer< Ty > init(const Ty &Val)
This instruction inserts a single (scalar) element into a VectorType value.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
Value * concatenateVectors(IRBuilder<> &Builder, ArrayRef< Value *> Vecs)
Concatenate a list of vectors.
LLVM Basic Block Representation.
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important class for using LLVM in a threaded context.
size_t size() const
size - Get the array size.
ConstantInt * getInt1(bool V)
Get a constant value representing either true or false.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This is an important base class in LLVM.
Constant * createReplicatedMask(IRBuilder<> &Builder, unsigned ReplicationFactor, unsigned VF)
Create a mask with replicated elements.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
TypeSize getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
EquivalenceClasses - This represents a collection of equivalence classes and supports three efficient...
member_iterator member_end() const
constexpr bool isPowerOf2_64(uint64_t Value)
Return true if the argument is a power of two > 0 (64 bit edition.)
uint32_t getIndex(const InstTy *Instr) const
Get the index for the given member.
Optional< VFInfo > tryDemangleForVFABI(StringRef MangledName)
Function to contruct a VFInfo out of a mangled names in the following format:
const SCEV * replaceSymbolicStrideSCEV(PredicatedScalarEvolution &PSE, const ValueToValueMap &PtrToStride, Value *Ptr, Value *OrigPtr=nullptr)
Return the SCEV corresponding to a pointer with the symbolic stride replaced with constant one...
Constant * createBitMaskForGaps(IRBuilder<> &Builder, unsigned VF, const InterleaveGroup< Instruction > &Group)
Create a mask that filters the members of an interleave group where there are gaps.
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
class_match< BinaryOperator > m_BinOp()
Match an arbitrary binary operation and ignore it.
static double log2(double V)
static MDNode * getMostGenericTBAA(MDNode *A, MDNode *B)
Type * getIndexedType() const
bool maskIsAllZeroOrUndef(Value *Mask)
Given a mask vector of the form <Y x="" i1>="">, Return true if all of the elements of this predicate...
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
uint64_t NextPowerOf2(uint64_t A)
Returns the next power of two (in 64-bits) that is strictly greater than A.
MDNode * uniteAccessGroups(MDNode *AccGroups1, MDNode *AccGroups2)
Compute the union of two access-group lists.
unsigned countLeadingZeros(T Val, ZeroBehavior ZB=ZB_Width)
Count number of 0's from the most significant bit to the least stopping at the first 1...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
void setMetadata(unsigned KindID, MDNode *Node)
Set the metadata of the specified kind to the specified node.
LLVM_READONLY APFloat maxnum(const APFloat &A, const APFloat &B)
Implements IEEE maxNum semantics.
bool isLoopInvariant(const Value *V) const
Return true if the specified value is loop invariant.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
A SetVector that performs no allocations if smaller than a certain size.
unsigned getNumOperands() const
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
const ElemTy & getOrInsertLeaderValue(const ElemTy &V)
getOrInsertLeaderValue - Return the leader for the specified value that is in the set...
This struct is a compact representation of a valid (power of two) or undefined (0) alignment...
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.
LLVM_NODISCARD std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
LLVM_NODISCARD T pop_back_val()
ConstantInt * getInt32(uint32_t C)
Get a constant 32-bit value.
Value * CreateShuffleVector(Value *V1, Value *V2, Value *Mask, const Twine &Name="")
reverse_iterator rbegin()
bool hasVectorInstrinsicScalarOpd(Intrinsic::ID ID, unsigned ScalarOpdIdx)
Identifies if the vector form of the intrinsic has a scalar operand.
APInt getDemandedBits(Instruction *I)
Return the bits demanded from instruction I.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Function * getFunction(StringRef Name) const
Look up the specified function in the module symbol table.
unsigned getVectorNumElements() const
Store the result of a depth first search within basic blocks contained by a single loop...
Class to represent vector types.
static void addToAccessGroupList(ListT &List, MDNode *AccGroups)
Add all access groups in AccGroups to List.
const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
Class for arbitrary precision integers.
iterator_range< user_iterator > users()
bool isPredicated(MCInstrInfo const &MCII, MCInst const &MCI)
void append(in_iter in_start, in_iter in_end)
Add the specified range to the end of the SmallVector.
Value * getUniqueCastUse(Value *Ptr, Loop *Lp, Type *Ty)
If a value has only one user that is a CastInst, return it.
Attribute getAttribute(unsigned i, Attribute::AttrKind Kind) const
Get the attribute of a given kind at a position.
Constant * createStrideMask(IRBuilder<> &Builder, unsigned Start, unsigned Stride, unsigned VF)
Create a stride shuffle mask.
unsigned getGEPInductionOperand(const GetElementPtrInst *Gep)
Find the operand of the GEP that should be checked for consecutive stores.
void analyzeInterleaving(bool EnableMaskedInterleavedGroup)
Analyze the interleaved accesses and collect them in interleave groups.
APInt possiblyDemandedEltsInMask(Value *Mask)
Given a mask vector of the form <Y x="" i1>="">, return an APInt (of bitwidth Y) for each lane which ...
This class represents an analyzed expression in the program.
LLVM_NODISCARD bool empty() const
StringRef getValueAsString() const
Return the attribute's value as a string.
Represents a single loop in the control flow graph.
APFloat abs(APFloat X)
Returns the absolute value of the argument.
bool mayReadFromMemory() const
Return true if this instruction may read memory.
Type * getResultElementType() const
uint32_t getFactor() const
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
OutputIt transform(R &&Range, OutputIt d_first, UnaryPredicate P)
Wrapper function around std::transform to apply a function to a range and store the result elsewhere...
Constant * createInterleaveMask(IRBuilder<> &Builder, unsigned VF, unsigned NumVecs)
Create an interleave shuffle mask.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
const SCEV * getSCEV(Value *V)
Return a SCEV expression for the full generality of the specified expression.
A vector that has set insertion semantics.
RPOIterator beginRPO() const
Reverse iterate over the cached postorder blocks.
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
StringRef - Represent a constant reference to a string, i.e.
unsigned getNumOperands() const
Return number of MDNode operands.
static MDNode * getMostGenericFPMath(MDNode *A, MDNode *B)
void addMetadata(InstTy *NewInst) const
Add metadata (e.g.
MaybeAlign getLoadStoreAlignment(Value *I)
A helper function that returns the alignment of load or store instruction.
uint32_t getNumMembers() const
static Constant * get(ArrayRef< Constant *> V)
Type * getElementType() const
LLVM_READONLY APFloat minnum(const APFloat &A, const APFloat &B)
Implements IEEE minNum semantics.
bool isValidAsAccessGroup(MDNode *AccGroup)
Return whether an MDNode might represent an access group.
const BasicBlock * getParent() const
This class represents a constant integer value.
bool requiresScalarEpilogue() const
Returns true if this Group requires a scalar iteration to handle gaps.
gep_type_iterator gep_type_begin(const User *GEP)
bool isTriviallyVectorizable(Intrinsic::ID ID)
Identify if the intrinsic is trivially vectorizable.
bool mayReadOrWriteMemory() const
Return true if this instruction may read or write memory.