49 case Instruction::Sub:
50 return Instruction::Add;
51 case Instruction::FSub:
52 return Instruction::FAdd;
59 if (
I->getOpcode() == Instruction::Sub)
61 if (
I->getOpcode() == Instruction::FSub)
62 return I->hasAllowReassoc();
63 return I->isAssociative();
71 switch (
I->getOpcode()) {
72 case Instruction::ExtractValue:
73 case Instruction::InsertValue:
75 case Instruction::ExtractElement:
78 case Instruction::InsertElement:
88 "ScalableVectorType is not supported.");
99 return std::min<unsigned>(PartNumElems,
Size - Part * PartNumElems);
107 OS <<
"Idx: " << Idx <<
", ";
108 OS <<
"n=" << VL.
size() <<
" [" << *VL.
front() <<
", ..]";
129 if (BB !=
II->getParent())
142 Value *FirstNonUndef =
nullptr;
143 for (
Value *V : VL) {
146 if (!FirstNonUndef) {
150 if (V != FirstNonUndef)
153 return FirstNonUndef !=
nullptr;
159 if ((LHS == Intrinsic::fma || LHS == Intrinsic::fmuladd) &&
160 (RHS == Intrinsic::fma || RHS == Intrinsic::fmuladd))
161 return Intrinsic::fma;
168 return Cmp->isCommutative();
170 return BO->isCommutative() ||
171 (BO->getOpcode() == Instruction::Sub && ValWithUses->
hasUseList() &&
178 if (match(U.getUser(),
179 m_ICmp(Pred, m_Specific(U.get()), m_Zero())) &&
180 (Pred == ICmpInst::ICMP_EQ || Pred == ICmpInst::ICMP_NE))
184 auto *I = dyn_cast<BinaryOperator>(U.get());
185 return match(U.getUser(),
186 m_Intrinsic<Intrinsic::abs>(
187 m_Specific(U.get()), m_ConstantInt(Flag))) &&
188 ((!IsCopyable && I && !I->hasNoSignedWrap()) ||
191 (BO->getOpcode() == Instruction::FSub && ValWithUses->
hasUseList() &&
194 return match(U.getUser(),
195 m_Intrinsic<Intrinsic::fabs>(m_Specific(U.get())));
197 return I->isCommutative();
205 "The instruction is not commutative.");
209 switch (BO->getOpcode()) {
210 case Instruction::Sub:
211 case Instruction::FSub:
217 return I->isCommutableOperand(
Op);
224 constexpr unsigned IntrinsicNumOperands = 2;
225 return IntrinsicNumOperands;
227 return I->getNumOperands();
242 Type *CurrentType =
IV->getType();
243 for (
unsigned I :
IV->indices()) {
245 Index *= ST->getNumElements();
246 CurrentType = ST->getElementType(
I);
248 Index *= AT->getNumElements();
249 CurrentType = AT->getElementType();
268 if (auto *CI = dyn_cast<CmpInst>(V))
269 return BasePred == CI->getPredicate();
270 if (auto *I = dyn_cast<Instruction>(V))
271 return I->getOpcode() == Opcode;
272 return isa<PoisonValue>(V);
277 unsigned Opcode = E->getOpcode();
278 assert((Opcode == Instruction::ExtractElement ||
279 Opcode == Instruction::ExtractValue) &&
280 "Expected extractelement or extractvalue instruction.");
281 if (Opcode == Instruction::ExtractElement) {
287 unsigned Idx = CI->getZExtValue();
295 if (EI->getNumIndices() != 1)
297 return *EI->idx_begin();
303 const unsigned E = Indices.
size();
305 for (
unsigned I = 0;
I < E; ++
I)
306 Mask[Indices[
I]] =
I;
310 assert(!Mask.empty() &&
"Expected non-empty mask.");
314 for (
unsigned I = 0, E = Prev.
size();
I < E; ++
I)
316 Scalars[Mask[
I]] = Prev[
I];
320 assert(!Mask.empty() && Reuses.
size() == Mask.size() &&
321 "Expected non-empty mask.");
324 for (
unsigned I = 0, E = Prev.
size();
I < E; ++
I)
326 Reuses[Mask[
I]] = Prev[
I];
331 assert(!Mask.empty() &&
"Expected non-empty mask.");
332 unsigned Sz = Mask.size();
337 std::iota(PrevOrder.
begin(), PrevOrder.
end(), 0);
339 PrevOrder.
swap(Order);
342 for (
unsigned I = 0;
I < Sz; ++
I)
344 Order[
I] = PrevOrder[Mask[
I]];
346 return Data.value() == Sz ||
Data.index() ==
Data.value();
357 std::iota(MaskOrder.
begin(), MaskOrder.
end(), 0);
367 for (
unsigned I = 0;
I < Sz; ++
I)
369 Order[MaskOrder[
I]] =
I;
375 "Order is empty. Please check it before using isReverseOrder.");
376 unsigned Sz = Order.
size();
378 return Pair.value() == Sz || Sz - Pair.index() - 1 == Pair.value();
386 for (
unsigned I = Sz, E = Mask.size();
I < E;
I += Sz) {
397 "Expected same size of orders");
398 size_t Sz = Order.
size();
401 if (Order[Idx] != Sz)
402 UsedIndices.
set(Order[Idx]);
404 if (SecondaryOrder.
empty()) {
406 if (Order[Idx] == Sz && !UsedIndices.
test(Idx))
410 if (SecondaryOrder[Idx] != Sz && Order[Idx] == Sz &&
411 !UsedIndices.
test(SecondaryOrder[Idx]))
412 Order[Idx] = SecondaryOrder[Idx];
417 assert(!VL.
empty() &&
"Expected non-empty list of values.");
419 return all_of(VL, [&](
Value *V) {
return V->getType() == Ty; });
425 static_assert(std::is_same_v<T, InsertElementInst> ||
426 std::is_same_v<T, ExtractElementInst>,
433 constexpr bool IsInsert = std::is_same_v<T, InsertElementInst>;
434 Type *VecTy = IsInsert ? IE->getType() : IE->getOperand(0)->getType();
441 if (CI->getValue().uge(VT->getNumElements()))
444 Index *= VT->getNumElements();
445 Index += CI->getZExtValue();
451template std::optional<unsigned>
453template std::optional<unsigned>
462 auto *IO = dyn_cast<Instruction>(V);
465 return isa<PHINode>(IO) || IO->getParent() != I->getParent();
474 return !
I->mayReadOrWriteMemory() && !
I->hasNUsesOrMore(
UsesLimit) &&
476 auto *IU = dyn_cast<Instruction>(U);
479 return IU->getParent() != I->getParent() || isa<PHINode>(IU);
488 return !VL.
empty() &&
501 I * VecTyNumElements, VecTyNumElements)))
503 : Mask[
I] * VecTyNumElements + J;
513 unsigned SVNumElements =
515 unsigned ShuffleMaskSize = SV->getShuffleMask().size();
516 if (SVNumElements % ShuffleMaskSize != 0)
518 unsigned GroupSize = SVNumElements / ShuffleMaskSize;
519 if (GroupSize == 0 || (VL.
size() % GroupSize) != 0)
521 unsigned NumGroup = 0;
522 for (
size_t I = 0, E = VL.
size();
I != E;
I += GroupSize) {
524 Value *Src = SV->getOperand(0);
530 if (SV->getOperand(0) != Src)
533 if (!SV->isExtractSubvectorMask(Index))
535 ExpectedIndex.
set(Index / ShuffleMaskSize);
539 if (!ExpectedIndex.
all())
543 assert(NumGroup == (VL.
size() / GroupSize) &&
"Unexpected number of groups");
550 unsigned SVNumElements =
553 unsigned AccumulateLength = 0;
554 for (
Value *V : VL) {
556 for (
int M : SV->getShuffleMask())
558 : AccumulateLength + M);
559 AccumulateLength += SVNumElements;
586std::optional<TargetTransformInfo::ShuffleKind>
599 return std::max(S, VTy->getNumElements());
602 Value *Vec1 =
nullptr;
603 Value *Vec2 =
nullptr;
608 Value *Vec = EE->getVectorOperand();
614 ShuffleMode CommonShuffleMode =
Unknown;
616 for (
unsigned I = 0, E = VL.
size();
I < E; ++
I) {
626 auto *Vec = EI->getVectorOperand();
640 if (Idx->getValue().uge(
Size))
642 unsigned IntIdx = Idx->getValue().getZExtValue();
649 if (!Vec1 || Vec1 == Vec) {
651 }
else if (!Vec2 || Vec2 == Vec) {
657 if (CommonShuffleMode == Permute)
661 if (Mask[
I] %
Size !=
I) {
662 CommonShuffleMode = Permute;
665 CommonShuffleMode =
Select;
668 if (CommonShuffleMode ==
Select && Vec2)
687 auto *Begin = std::next(Mask.begin(), Index);
688 std::iota(Begin, std::next(Begin, SubVecVF), 0);
689 Vec = Builder.CreateShuffleVector(V, Mask);
692 std::iota(Mask.begin(), Mask.end(), 0);
693 std::iota(std::next(Mask.begin(), Index),
694 std::next(Mask.begin(), Index + SubVecVF), VecVF);
696 return Generator(Vec, V, Mask);
699 std::iota(ResizeMask.
begin(), std::next(ResizeMask.
begin(), SubVecVF), 0);
700 V = Builder.CreateShuffleVector(V, ResizeMask);
702 return Builder.CreateShuffleVector(Vec, V, Mask);
706 unsigned SubVecVF,
unsigned Index) {
708 std::iota(Mask.begin(), Mask.end(), Index);
709 return Builder.CreateShuffleVector(Vec, Mask);
728template <
bool IsPoisonOnly>
731 using T = std::conditional_t<IsPoisonOnly, PoisonValue, UndefValue>;
765 for (
unsigned I = 0, E = VecTy->getNumElements();
I != E; ++
I) {
766 if (
Constant *Elem =
C->getAggregateElement(
I))
786 case Instruction::Load: {
790 case Instruction::Store: {
792 return (
SI->getPointerOperand() == Scalar);
794 case Instruction::Call: {
798 return isVectorIntrinsicWithScalarOpAtArg(ID, Arg.index(), TTI) &&
799 Arg.value().get() == Scalar;
817 return LI->isSimple();
819 return SI->isSimple();
821 return !
MI->isVolatile();
831 uint64_t ScalarSize =
DL.getTypeStoreSize(ScalarTy);
832 Conditions.
assign(PointerOps.
size(),
nullptr);
837 APInt OffsetAP(
DL.getIndexTypeSizeInBits(
GEP->getType()), 0);
838 if (!
GEP->accumulateConstantOffset(
DL, OffsetAP) || OffsetAP.
isNegative())
841 Base =
GEP->getPointerOperand();
846 Value *
T = Sel->getTrueValue();
847 Value *
F = Sel->getFalseValue();
853 }
else if (TrueBase !=
T || FalseBase !=
F) {
858 if (
Offset !=
static_cast<uint64_t
>(Idx) * ScalarSize)
860 Conditions[Idx] = Sel->getCondition();
862 return TrueBase !=
nullptr;
866 bool ExtendingManyInputs) {
870 (!ExtendingManyInputs || SubMask.
size() > Mask.size() ||
873 "SubMask with many inputs support must be larger than the mask.");
875 Mask.append(SubMask.
begin(), SubMask.
end());
879 int TermValue = std::min(Mask.size(), SubMask.
size());
880 for (
int I = 0, E = SubMask.
size();
I < E; ++
I) {
882 (!ExtendingManyInputs &&
883 (SubMask[
I] >= TermValue || Mask[SubMask[
I]] >= TermValue)))
885 NewMask[
I] = Mask[SubMask[
I]];
891 const size_t Sz = Order.
size();
894 for (
unsigned I = 0;
I < Sz; ++
I) {
896 UnusedIndices.
reset(Order[
I]);
898 MaskedIndices.
set(
I);
900 if (MaskedIndices.
none())
903 "Non-synced masked/available indices.");
907 assert(Idx >= 0 &&
"Indices must be synced.");
915 unsigned Opcode0,
unsigned Opcode1) {
922 OpcodeMask.
set(Lane * ScalarTyNumElements,
923 Lane * ScalarTyNumElements + ScalarTyNumElements);
930 "Expected scalar constants.");
933 std::fill_n(NewVal.begin() +
I * VF, VF, V);
939 case Instruction::UDiv:
940 return Intrinsic::masked_udiv;
941 case Instruction::SDiv:
942 return Intrinsic::masked_sdiv;
943 case Instruction::URem:
944 return Intrinsic::masked_urem;
945 case Instruction::SRem:
946 return Intrinsic::masked_srem;
957 constexpr unsigned MaxIndexChainLength = 3;
960 auto IsProfitableOperand = [](
const Value *V) {
964 V = Cast->getOperand(0);
967 const User *U =
I->user_back();
968 for ([[maybe_unused]]
unsigned _ :
seq<unsigned>(MaxIndexChainLength)) {
971 none_of(
I->operand_values(), IsProfitableOperand);
985 unsigned Opcode = BO->getOpcode();
986 Type *Ty = BO->getType();
990 Opcode, Ty, Idx == 1) ||
992 Opcode, Ty, Idx == 0)))
996 const User *U =
I->user_back();
1008 if (!Wide || !Wide->hasOneUse())
1011 if (!Narrow || !Narrow->hasOneUse())
1013 Value *Src = Narrow->getOperand(0);
1016 if (MustBeElidable && !(Wide->hasAllowContract() && Wide->hasNoNaNs() &&
1017 Wide->hasNoInfs() && Narrow->hasAllowContract()))
1027struct NarrowedChainState {
1029 unsigned NarrowShift = 0;
1030 unsigned NarrowBW = 0;
1048 NarrowedChainState S,
unsigned Depth,
1052 if (
Depth < MaxDepth) {
1054 Z && Z->getSrcTy()->isIntegerTy() && !Z->getSrcTy()->isIntegerTy(1)) {
1057 Depth + 1, MaxDepth, Leaves, ChainInsts);
1060 if (BO->getOpcode() == RdxOpcode) {
1063 Depth + 1, MaxDepth, Leaves, ChainInsts);
1065 Depth + 1, MaxDepth, Leaves, ChainInsts);
1069 unsigned BW = V->getType()->getScalarSizeInBits();
1071 if (BO->getOpcode() == Instruction::Shl && Z && S.NarrowBW == 0 &&
1073 Z->getSrcTy()->isIntegerTy() && !Z->getSrcTy()->isIntegerTy(1) &&
1075 Z->getSrcTy()->getIntegerBitWidth() + Amt->
getZExtValue() <= BW) &&
1081 Depth + 1, MaxDepth, Leaves,
1088 if (BW < WideBW && (S.NarrowBW == 0 || BW == S.NarrowBW)) {
1089 if (BO->getOpcode() == Instruction::Shl &&
1092 S.Shift + S.NarrowShift + Amt->
getZExtValue() < WideBW) {
1094 if (BO->hasNoUnsignedWrap() && S.NarrowBW == 0) {
1101 if (S.NarrowBW == 0) {
1108 S,
Depth + 1, MaxDepth, Leaves,
1114 if (S.NarrowBW == 0) {
1118 S.NarrowMask &= *Amt << S.NarrowShift;
1120 MaxDepth, Leaves, ChainInsts);
1126 S.getMask(V->getType()->getScalarSizeInBits()));
1134 0, MaxDepth, Leaves, ChainInsts);
1138 assert(
F &&
"Expected function.");
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
AMDGPU Register Bank Select
This file implements a class to represent arbitrary precision integral constant values and operations...
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
static std::pair< Value *, APInt > getMask(Value *WideMask, unsigned Factor, ElementCount LeafValueEC)
uint64_t IntrinsicInst * II
Provides some synthesis utilities to produce sequences of values.
static const uint32_t IV[8]
Class for arbitrary precision integers.
static APInt getAllOnes(unsigned numBits)
Return an APInt of a specified width with all bits set.
uint64_t getZExtValue() const
Get zero extended value.
bool ult(const APInt &RHS) const
Unsigned less than comparison.
bool isNegative() const
Determine sign of this APInt.
static APInt getLowBitsSet(unsigned numBits, unsigned loBitsSet)
Constructs an APInt value that has the bottom loBitsSet bits set.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
const T & front() const
Get the first element.
size_t size() const
Get the array size.
bool empty() const
Check if the array is empty.
ArrayRef< T > slice(size_t N, size_t M) const
slice(n, m) - Chop off the first N elements of the array, and keep M elements in the array.
const T & consume_front()
consume_front() - Returns the first element and drops it from ArrayRef.
A cache of @llvm.assume calls within a function.
LLVM Basic Block Representation.
iterator_range< User::op_iterator > args()
Iteration adapter for range-for loops.
This class represents a function call, abstracting a target machine's calling convention.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
static LLVM_ABI Constant * getBinOpAbsorber(unsigned Opcode, Type *Ty, bool AllowLHSConstant=false)
Return the absorbing element for the given binary operation, i.e.
static LLVM_ABI Constant * getBinOpIdentity(unsigned Opcode, Type *Ty, bool AllowRHSConstant=false, bool NSZ=false)
Return the identity constant for a binary opcode.
This is an important base class in LLVM.
A parsed version of the target data layout string in and methods for querying it.
Common base class shared among various IRBuilders.
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
An instruction for reading from memory.
Value * getPointerOperand()
This is the common base class for memset/memcpy/memmove.
Representation for a specific memory location.
static LLVM_ABI MemoryLocation get(const LoadInst *LI)
Return a location with information about the memory reference by the given instruction.
Represent a mutable reference to an array (0 or more elements consecutively in memory),...
static LLVM_ABI PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
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...
This is a 'bitvector' (really, a variable-sized bit array), optimized for the case when the array is ...
int find_first() const
Returns the index of the first set bit, -1 if none of the bits are set.
bool test(unsigned Idx) const
Returns true if bit Idx is set.
int find_next(unsigned Prev) const
Returns the index of the next set bit following the "Prev" bit.
bool all() const
Returns true if all bits are set.
size_type count() const
Returns the number of bits which are set.
bool none() const
Returns true if none of the bits are set.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void assign(size_type NumElts, ValueParamT Elt)
reference emplace_back(ArgTypes &&... Args)
void swap(SmallVectorImpl &RHS)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
An instruction for storing to memory.
Provides information about what library functions are available for the current target.
The instances of the Type class are immutable: once they are created, they are never changed.
A Use represents the edge between a Value definition and its users.
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
bool hasUseList() const
Check if this Value has a use-list.
LLVM_ABI bool hasNUsesOrMore(unsigned N) const
Return true if this value has N uses or more.
iterator_range< use_iterator > uses()
constexpr ScalarTy getFixedValue() const
An efficient, type-erasing, non-owning reference to a callable.
const ParentTy * getParent() const
A raw_ostream that writes to an std::string.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
ap_match< APInt > m_APInt(const APInt *&Res)
Match a ConstantInt or splatted ConstantVector, binding the specified pointer to the contained APInt.
BinaryOp_match< LHS, RHS, Instruction::And, true > m_c_And(const LHS &L, const RHS &R)
Matches an And with LHS and RHS in either order.
bool match(Val *V, const Pattern &P)
auto m_Value()
Match an arbitrary value and ignore it.
A private "module" namespace for types and utilities used by this pass.
std::optional< unsigned > getExtractIndex(const Instruction *E)
template SmallBitVector isUndefVector< true >(const Value *, const SmallBitVector &)
Value * createInsertVector(IRBuilderBase &Builder, Value *Vec, Value *V, unsigned Index, function_ref< Value *(Value *, Value *, ArrayRef< int >)> Generator)
Creates subvector insert.
bool areAllOperandsNonInsts(Value *V)
Checks if the provided value does not require scheduling.
std::optional< unsigned > getElementIndex(const Value *Inst, unsigned Offset)
bool doesInTreeUserNeedToExtract(Value *Scalar, Instruction *UserInst, TargetLibraryInfo *TLI, const TargetTransformInfo *TTI)
MemoryLocation getLocation(Instruction *I)
bool isSelectedBaseLoad(Type *ScalarTy, ArrayRef< Value * > PointerOps, const DataLayout &DL, Value *&TrueBase, Value *&FalseBase, SmallVectorImpl< Value * > &Conditions)
Checks if the loads with scalar type ScalarTy and pointer operands PointerOps are each (optionally vi...
SmallBitVector getAltInstrMask(ArrayRef< Value * > VL, Type *ScalarTy, unsigned Opcode0, unsigned Opcode1)
SmallBitVector isUndefVector(const Value *V, const SmallBitVector &UseMask)
Checks if the given value is actually an undefined constant vector.
Intrinsic::ID getMaskedDivRemIntrinsic(unsigned Opcode)
bool isUsedOutsideBlock(Value *V)
Checks if the provided value does not require scheduling.
bool doesNotNeedToSchedule(ArrayRef< Value * > VL)
Checks if the specified array of instructions does not require scheduling.
std::optional< unsigned > getInsertExtractIndex(const Value *Inst, unsigned Offset)
void reorderScalars(SmallVectorImpl< Value * > &Scalars, ArrayRef< int > Mask)
Reorders the list of scalars in accordance with the given Mask.
bool allSameType(ArrayRef< Value * > VL)
void combineOrders(MutableArrayRef< unsigned > Order, ArrayRef< unsigned > SecondaryOrder)
Fills unset elements of Order (marked with the sentinel value equal to the order size) with the corre...
bool allSameOpcode(ArrayRef< Value * > VL)
bool isSplat(ArrayRef< Value * > VL)
unsigned getNumElements(Type *Ty)
std::string shortBundleName(ArrayRef< Value * > VL, int Idx)
Print a short descriptor of the instruction bundle suitable for debug output.
bool isOnceUsedSeed(const Instruction *I)
Returns true if I forms a vectorizable bundle on its own and its single user does not tear the vector...
unsigned getPartNumElems(unsigned Size, unsigned NumParts)
Returns power-of-2 number of elements in a single register (part), given the total number of elements...
bool isCommutableOperand(const Instruction *I, Value *ValWithUses, unsigned Op, bool IsCopyable)
Checks if the operand is commutative.
TargetTransformInfo::TargetCostKind getSLPCostKind(const Function *F)
bool isReverseOrder(ArrayRef< unsigned > Order)
Check if Order represents reverse order.
void transformScalarShuffleIndiciesToVector(unsigned VecTyNumElements, SmallVectorImpl< int > &Mask)
SmallVector< int > calculateShufflevectorMask(ArrayRef< Value * > VL)
SmallBitVector buildUseMask(int VF, ArrayRef< int > Mask, UseMask MaskArg)
Prepares a use bitset for the given mask either for the first argument or for the second.
bool isCommutative(const Instruction *I, const Value *ValWithUses, bool IsCopyable)
template SmallBitVector isUndefVector< false >(const Value *, const SmallBitVector &)
unsigned getNumberOfPotentiallyCommutativeOps(Instruction *I)
bool allConstant(ArrayRef< Value * > VL)
template std::optional< unsigned > getInsertExtractIndex< InsertElementInst >(const Value *, unsigned)
void inversePermutation(ArrayRef< unsigned > Indices, SmallVectorImpl< int > &Mask)
Compute the inverse permutation Mask of Indices.
bool allSameBlock(ArrayRef< Value * > VL)
bool isReassocChainLink(const Instruction *I)
Intrinsic::ID isEquivalentIntrinsicID(Intrinsic::ID LHS, Intrinsic::ID RHS)
Checks if LHS and RHS are the same intrinsic, or one is llvm.fma and the other is llvm....
UseMask
Specifies the way the mask should be analyzed for undefs/poisonous elements in the shuffle mask.
@ SecondArg
The mask is expected to be for permutation of 2 vectors, check for the mask elements for the second a...
@ UndefsAsMask
Consider undef mask elements (-1) as placeholders for future shuffle elements and mark them as ones a...
@ FirstArg
The mask is expected to be for permutation of 1-2 vectors, check for the mask elements for the first ...
void reorderOrder(SmallVectorImpl< unsigned > &Order, ArrayRef< int > Mask, bool BottomOrder)
Reorders the given Order according to the given Mask.
static void collectNarrowedLeavesImpl(Value *V, unsigned RdxOpcode, unsigned WideBW, NarrowedChainState S, unsigned Depth, unsigned MaxDepth, SmallVectorImpl< NarrowedLeafInfo > &Leaves, SmallVectorImpl< Instruction * > &ChainInsts)
void reorderReuses(SmallVectorImpl< int > &Reuses, ArrayRef< int > Mask)
Reorders the given Reuses mask according to the given Mask.
void addMask(SmallVectorImpl< int > &Mask, ArrayRef< int > SubMask, bool ExtendingManyInputs)
Shuffles Mask in accordance with the given SubMask.
bool isSimple(Instruction *I)
Instruction * lookThroughCastRoundTrip(Value *V, bool MustBeElidable)
If V is a single-use fpext of a single-use fptrunc forming a round-trip back to the type of V,...
bool isBinOpIdentityConstant(const Value *V, unsigned Opcode)
unsigned getShufflevectorNumGroups(ArrayRef< Value * > VL)
std::optional< TargetTransformInfo::ShuffleKind > isFixedVectorShuffle(ArrayRef< Value * > VL, SmallVectorImpl< int > &Mask, AssumptionCache *AC)
Checks if the vector of instructions can be represented as a shuffle, like: x0 = extractelement <4 x ...
SmallVector< Constant * > replicateMask(ArrayRef< Constant * > Val, unsigned VF)
Replicates the given Val VF times.
unsigned getReassocCombineOpcode(unsigned Opcode)
bool isVectorLikeInstWithConstOps(Value *V)
Checks if V is one of vector-like instructions, i.e.
bool doesNotNeedToBeScheduled(Value *V)
Checks if the specified value does not require scheduling.
unsigned getNumElems(unsigned Size, unsigned PartNumElems, unsigned Part)
Returns correct remaining number of elements, considering total amount Size, (power-of-2 number) of e...
constexpr int UsesLimit
Limit of the number of uses for potentially transformed instructions/values, used in checks to avoid ...
void collectNarrowedLeaves(Value *V, unsigned RdxOpcode, unsigned WideBW, unsigned MaxDepth, SmallVectorImpl< NarrowedLeafInfo > &Leaves, SmallVectorImpl< Instruction * > &ChainInsts)
Recursively collects the narrow leaves of the widened reduction value V.
bool isRepeatedNonIdentityClusteredMask(ArrayRef< int > Mask, unsigned Sz)
Checks if the given mask is a "clustered" mask with the same clusters of size Sz, which are not ident...
bool isConstant(Value *V)
static bool isNonProfitableIndex(const Instruction *I)
Returns true if I is a part of a single-use chain, computing an address, which does not pay off the v...
Value * createExtractVector(IRBuilderBase &Builder, Value *Vec, unsigned SubVecVF, unsigned Index)
Generates subvector extract using Generator or using default shuffle.
template std::optional< unsigned > getInsertExtractIndex< ExtractElementInst >(const Value *, unsigned)
void fixupOrderingIndices(MutableArrayRef< unsigned > Order)
Order may have elements assigned special value (size) which is out of bounds.
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.
LLVM_ABI Intrinsic::ID getVectorIntrinsicIDForCall(const CallInst *CI, const TargetLibraryInfo *TLI)
Returns intrinsic ID for call.
@ Unknown
Not known to have no common set bits.
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are tuples (A, B,...
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
auto accumulate(R &&Range, E &&Init)
Wrapper for std::accumulate.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
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...
T bit_ceil(T Value)
Returns the smallest integral power of two no smaller than Value if Value is nonzero.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
ElementCount getVectorizedTypeVF(Type *Ty)
Returns the number of vector elements for a vectorized type.
bool none_of(R &&Range, UnaryPredicate P)
Provide wrappers to std::none_of which take ranges instead of having to pass begin/end explicitly.
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...
MutableArrayRef(T &OneElt) -> MutableArrayRef< T >
constexpr int PoisonMaskElem
iterator_range(Container &&) -> iterator_range< llvm::detail::IterOfRange< Container > >
constexpr T divideCeil(U Numerator, V Denominator)
Returns the integer ceil(Numerator / Denominator).
DWARFExpression::Operation Op
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
constexpr auto seq(T Begin, T End)
Iterate over an integral type from Begin up to - but not including - End.
LLVM_ABI bool isGuaranteedNotToBePoison(const Value *V, AssumptionCache *AC=nullptr, const Instruction *CtxI=nullptr, const DominatorTree *DT=nullptr, unsigned Depth=0)
Returns true if V cannot be poison, but may be undef.
LLVM_ABI bool mayHaveNonDefUseDependency(const Instruction &I)
Returns true if the result or effects of the given instructions I depend values not reachable through...
constexpr detail::IsaCheckPredicate< Types... > IsaPred
Function object wrapper for the llvm::isa type check.