43 case Intrinsic::log10:
48 case Intrinsic::copysign:
49 case Intrinsic::floor:
51 case Intrinsic::trunc:
53 case Intrinsic::nearbyint:
55 case Intrinsic::bswap:
56 case Intrinsic::bitreverse:
57 case Intrinsic::ctpop:
60 case Intrinsic::fmuladd:
73 unsigned ScalarOpdIdx) {
78 return (ScalarOpdIdx == 1);
94 ID == Intrinsic::lifetime_end || ID == Intrinsic::assume ||
95 ID == Intrinsic::sideeffect)
112 std::advance(GEPTI, LastOperand - 2);
137 if (i != InductionOperand &&
145 Value *UniqueCast =
nullptr;
148 if (CI && CI->
getType() == Ty) {
162 if (!PtrTy || PtrTy->isAggregateType())
168 Value *OrigPtr = Ptr;
171 int64_t PtrAccessSize = 1;
191 if (OrigPtr == Ptr) {
192 if (
const SCEVMulExpr *M = dyn_cast<SCEVMulExpr>(V)) {
193 if (M->getOperand(0)->getSCEVType() !=
scConstant)
196 const APInt &APStepVal = cast<SCEVConstant>(M->getOperand(0))->getAPInt();
203 if (PtrAccessSize != StepVal)
205 V = M->getOperand(1);
210 Type *StripedOffRecurrenceCast =
nullptr;
212 StripedOffRecurrenceCast =
C->
getType();
227 if (StripedOffRecurrenceCast)
244 return C->getAggregateElement(EltNo);
248 if (!isa<ConstantInt>(III->getOperand(2)))
250 unsigned IIElt = cast<ConstantInt>(III->getOperand(2))->getZExtValue();
255 return III->getOperand(1);
264 int InEl = SVI->getMaskValue(EltNo);
267 if (InEl < (
int)LHSWidth)
276 if (Elt->isNullValue())
290 if (
auto *
C = dyn_cast<Constant>(V))
291 if (isa<VectorType>(V->
getType()))
292 return C->getSplatValue();
298 for (
int MaskElt : ShuffleInst->getShuffleMask())
299 if (MaskElt != 0 && MaskElt != -1)
302 auto *InsertEltInst =
304 if (!InsertEltInst || !isa<ConstantInt>(InsertEltInst->getOperand(2)) ||
305 !cast<ConstantInt>(InsertEltInst->getOperand(2))->
isZero())
327 bool SeenExtFromIllegalType =
false;
328 for (
auto *BB : Blocks)
329 for (
auto &
I : *BB) {
332 if (TTI && (isa<ZExtInst>(&
I) || isa<SExtInst>(&
I)) &&
334 SeenExtFromIllegalType =
true;
337 if ((isa<TruncInst>(&
I) || isa<ICmpInst>(&
I)) &&
338 !
I.getType()->isVectorTy() &&
339 I.getOperand(0)->getType()->getScalarSizeInBits() <= 64) {
342 if (TTI && isa<TruncInst>(&
I) && TTI->
isTypeLegal(
I.getType()))
350 if (Worklist.
empty() || (TTI && !SeenExtFromIllegalType))
354 while (!Worklist.
empty()) {
358 if (Visited.
count(Val))
363 if (!isa<Instruction>(Val))
378 if (isa<SExtInst>(I) || isa<ZExtInst>(I) || isa<LoadInst>(I) ||
379 !InstructionSet.
count(I))
385 if (isa<BitCastInst>(I) || isa<PtrToIntInst>(
I) || isa<IntToPtrInst>(I) ||
387 DBits[Leader] |= ~0ULL;
397 if (DBits[Leader] == ~0ULL)
401 for (
Value *
O : cast<User>(I)->operands()) {
410 for (
auto &
I : DBits)
411 for (
auto *U :
I.first->users())
412 if (U->getType()->isIntegerTy() && DBits.count(U) == 0)
416 uint64_t LeaderDemandedBits = 0;
418 LeaderDemandedBits |= DBits[*
MI];
420 uint64_t MinBW = (
sizeof(LeaderDemandedBits) * 8) -
432 if (isa<PHINode>(*
MI) && MinBW < (*MI)->getType()->getScalarSizeInBits()) {
440 if (!isa<Instruction>(*
MI))
442 Type *Ty = (*MI)->getType();
444 Ty = cast<Instruction>(*MI)->getOperand(0)->getType();
445 if (MinBW < Ty->getScalarSizeInBits())
446 MinBWs[cast<Instruction>(*MI)] = MinBW;
465 for (
int J = 1,
E = VL.
size(); MD && J !=
E; ++J) {
497 for (
unsigned i = 0; i < VF; i++)
498 for (
unsigned j = 0; j < NumVecs; j++)
505 unsigned Stride,
unsigned VF) {
507 for (
unsigned i = 0; i < VF; i++)
514 unsigned NumInts,
unsigned NumUndefs) {
516 for (
unsigned i = 0; i < NumInts; i++)
520 for (
unsigned i = 0; i < NumUndefs; i++)
533 assert(VecTy1 && VecTy2 &&
535 "Expect two vectors with the same element type");
538 unsigned NumElts2 = VecTy2->getNumElements();
539 assert(NumElts1 >= NumElts2 &&
"Unexpect the first vector has less elements");
541 if (NumElts1 > NumElts2) {
553 unsigned NumVecs = Vecs.
size();
554 assert(NumVecs > 1 &&
"Should be at least two vectors");
560 for (
unsigned i = 0; i < NumVecs - 1; i += 2) {
561 Value *V0 = ResList[i], *V1 = ResList[i + 1];
562 assert((V0->
getType() == V1->getType() || i == NumVecs - 2) &&
563 "Only the last vector may have a different type");
569 if (NumVecs % 2 != 0)
573 NumVecs = ResList.
size();
574 }
while (NumVecs > 1);
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.
void push_back(const T &Elt)
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. ...
class_match< Value > m_Value()
Match an arbitrary value and ignore it.
uint64_t getZExtValue() const
Get zero extended 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.
Value * findScalarElement(Value *V, unsigned EltNo)
Given a vector and an element number, see if the scalar value is already around as a register...
Compute iterated dominance frontiers using a linear time algorithm.
const Value * getSplatValue(const Value *V)
Get splat value if the input is a splat vector or return nullptr.
Instruction * propagateMetadata(Instruction *I, ArrayRef< Value *> VL)
Specifically, let Kinds = [MD_tbaa, MD_alias_scope, MD_noalias, MD_fpmath, MD_nontemporal].
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.
class_match< Constant > m_Constant()
Match an arbitrary Constant and ignore it.
static uint64_t round(uint64_t Acc, uint64_t Input)
This instruction constructs a fixed permutation of two input vectors.
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.
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.
std::size_t 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...
This is the base class for unary cast operator classes.
unsigned getBitWidth() const
Return the number of bits in the APInt.
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.
IntegerType * getInt32Ty()
Fetch the type representing a 32-bit integer.
bool match(Val *V, const Pattern &P)
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.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
uint64_t getNumElements() const
This node represents multiplication of some number of SCEVs.
BinaryOp_match< LHS, RHS, Instruction::Add > m_Add(const LHS &L, const RHS &R)
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.
member_iterator member_begin(iterator I) const
This node represents a polynomial recurrence on the trip count of the specified loop.
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)...
static MDNode * intersect(MDNode *A, MDNode *B)
const SCEV * getStepRecurrence(ScalarEvolution &SE) const
Constructs and returns the recurrence indicating how much this expression steps by.
Value * getOperand(unsigned i) const
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'.
Value * getOperand(unsigned i_nocapture) const
an instruction for type-safe pointer arithmetic to access elements of arrays and structs ...
This means that we are dealing with an entirely unknown SCEV value, and only represent it as its LLVM...
This instruction inserts a single (scalar) element into a VectorType value.
Value * concatenateVectors(IRBuilder<> &Builder, ArrayRef< Value *> Vecs)
Concatenate a list of vectors.
The instances of the Type class are immutable: once they are created, they are never changed...
size_t size() const
size - Get the array size.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This is an important base class in LLVM.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
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.)
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
static double log2(double V)
static MDNode * getMostGenericTBAA(MDNode *A, MDNode *B)
Type * getIndexedType() const
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.
#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.
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 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 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="")
bool hasVectorInstrinsicScalarOpd(Intrinsic::ID ID, unsigned ScalarOpdIdx)
Identifies if the intrinsic has a scalar operand.
APInt getDemandedBits(Instruction *I)
Return the bits demanded from instruction I.
unsigned getVectorNumElements() const
Class to represent vector types.
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()
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.
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.
uint64_t getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
static bool isZero(Value *V, const DataLayout &DL, DominatorTree *DT, AssumptionCache *AC)
This class represents an analyzed expression in the program.
LLVM_NODISCARD bool empty() const
Represents a single loop in the control flow graph.
Type * getResultElementType() 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)
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.
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.
static MDNode * getMostGenericFPMath(MDNode *A, MDNode *B)
static Constant * get(ArrayRef< Constant *> V)
LLVM_READONLY APFloat minnum(const APFloat &A, const APFloat &B)
Implements IEEE minNum semantics.
std::vector< uint32_t > Metadata
PAL metadata represented as a vector.
gep_type_iterator gep_type_begin(const User *GEP)
bool isTriviallyVectorizable(Intrinsic::ID ID)
Identify if the intrinsic is trivially vectorizable.