28 using namespace llvm::PatternMatch;
42 case Intrinsic::log10:
47 case Intrinsic::copysign:
48 case Intrinsic::floor:
50 case Intrinsic::trunc:
52 case Intrinsic::nearbyint:
54 case Intrinsic::bswap:
55 case Intrinsic::bitreverse:
56 case Intrinsic::ctpop:
59 case Intrinsic::fmuladd:
72 unsigned ScalarOpdIdx) {
77 return (ScalarOpdIdx == 1);
93 ID == Intrinsic::lifetime_end || ID == Intrinsic::assume)
135 if (
i != InductionOperand &&
143 Value *UniqueCast =
nullptr;
146 if (CI && CI->
getType() == Ty) {
160 if (!PtrTy || PtrTy->isAggregateType())
169 int64_t PtrAccessSize = 1;
189 if (OrigPtr == Ptr) {
190 if (
const SCEVMulExpr *M = dyn_cast<SCEVMulExpr>(V)) {
191 if (M->getOperand(0)->getSCEVType() !=
scConstant)
194 const APInt &APStepVal = cast<SCEVConstant>(M->getOperand(0))->getAPInt();
201 if (PtrAccessSize != StepVal)
203 V = M->getOperand(1);
208 Type *StripedOffRecurrenceCast =
nullptr;
210 StripedOffRecurrenceCast =
C->getType();
225 if (StripedOffRecurrenceCast)
242 return C->getAggregateElement(EltNo);
246 if (!isa<ConstantInt>(III->getOperand(2)))
248 unsigned IIElt = cast<ConstantInt>(III->getOperand(2))->getZExtValue();
253 return III->getOperand(1);
262 int InEl = SVI->getMaskValue(EltNo);
265 if (InEl < (
int)LHSWidth)
274 if (Elt->isNullValue())
288 if (
auto *
C = dyn_cast<Constant>(V))
289 if (isa<VectorType>(V->
getType()))
290 return C->getSplatValue();
296 for (
int MaskElt : ShuffleInst->getShuffleMask())
297 if (MaskElt != 0 && MaskElt != -1)
300 auto *InsertEltInst =
302 if (!InsertEltInst || !isa<ConstantInt>(InsertEltInst->getOperand(2)) ||
303 !cast<ConstantInt>(InsertEltInst->getOperand(2))->isNullValue())
325 bool SeenExtFromIllegalType =
false;
326 for (
auto *BB : Blocks)
327 for (
auto &
I : *BB) {
330 if (TTI && (isa<ZExtInst>(&
I) || isa<SExtInst>(&
I)) &&
332 SeenExtFromIllegalType =
true;
335 if ((isa<TruncInst>(&
I) || isa<ICmpInst>(&
I)) &&
336 !
I.getType()->isVectorTy() &&
337 I.getOperand(0)->getType()->getScalarSizeInBits() <= 64) {
340 if (TTI && isa<TruncInst>(&
I) && TTI->
isTypeLegal(
I.getType()))
348 if (Worklist.
empty() || (TTI && !SeenExtFromIllegalType))
352 while (!Worklist.
empty()) {
356 if (Visited.
count(Val))
361 if (!isa<Instruction>(Val))
376 if (isa<SExtInst>(I) || isa<ZExtInst>(I) || isa<LoadInst>(I) ||
377 !InstructionSet.
count(I))
383 if (isa<BitCastInst>(I) || isa<PtrToIntInst>(
I) || isa<IntToPtrInst>(I) ||
385 DBits[Leader] |= ~0ULL;
395 if (DBits[Leader] == ~0ULL)
399 for (
Value *O : cast<User>(I)->operands()) {
408 for (
auto &
I : DBits)
409 for (
auto *U :
I.first->users())
410 if (U->getType()->isIntegerTy() && DBits.count(U) == 0)
414 uint64_t LeaderDemandedBits = 0;
416 LeaderDemandedBits |= DBits[*
MI];
418 uint64_t MinBW = (
sizeof(LeaderDemandedBits) * 8) -
430 if (isa<PHINode>(*
MI) && MinBW < (*MI)->getType()->getScalarSizeInBits()) {
438 if (!isa<Instruction>(*
MI))
440 Type *Ty = (*MI)->getType();
442 Ty = cast<Instruction>(*MI)->getOperand(0)->getType();
443 if (MinBW < Ty->getScalarSizeInBits())
444 MinBWs[cast<Instruction>(*MI)] = MinBW;
463 for (
int J = 1,
E = VL.
size(); MD && J !=
E; ++J) {
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. ...
Type * getIndexedType() const
class_match< Value > m_Value()
Match an arbitrary value and ignore it.
uint64_t getZExtValue() const
Get zero extended value.
Value * findScalarElement(Value *V, unsigned EltNo)
Given a vector and an element number, see if the scalar value is already around as a register...
match_zero m_Zero()
Match an arbitrary zero/null constant.
const Value * getSplatValue(const Value *V)
Get splat value if the input is a splat vector or return nullptr.
unsigned getNumOperands() const
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.
size_type count(PtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
class_match< Constant > m_Constant()
Match an arbitrary Constant and ignore it.
static uint64_t round(uint64_t Acc, uint64_t Input)
const SCEV * getStepRecurrence(ScalarEvolution &SE) const
Constructs and returns the recurrence indicating how much this expression steps by.
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...
member_iterator member_begin(iterator I) const
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.
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.
bool match(Val *V, const Pattern &P)
This is the base class for all instructions that perform data casts.
static void advance(T &it, size_t Val)
member_iterator member_end() const
bool isLoopInvariant(const Value *V) const
Return true if the specified value is loop invariant.
This node represents multiplication of some number of SCEVs.
BinaryOp_match< LHS, RHS, Instruction::Add > m_Add(const LHS &L, const RHS &R)
LLVM_NODISCARD bool empty() const
This node represents a polynomial recurrence on the trip count of the specified loop.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
static MDNode * intersect(MDNode *A, MDNode *B)
size_t size() const
size - Get the array size.
Class to represent pointers.
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
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.
The instances of the Type class are immutable: once they are created, they are never changed...
void getAllMetadataOtherThanDebugLoc(SmallVectorImpl< std::pair< unsigned, MDNode * >> &MDs) const
This does the same thing as getAllMetadata, except that it filters out the debug location.
bool isVectorTy() const
True if this is an instance of VectorType.
This is an important base class in LLVM.
int64_t getSExtValue() const
Get sign extended value.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
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.
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...
constexpr bool isPowerOf2_64(uint64_t Value)
isPowerOf2_64 - This function returns true if the argument is a power of two 0 (64 bit edition...
unsigned getBitWidth() const
Return the number of bits in the APInt.
uint64_t getNumElements() const
Value * getOperand(unsigned i) const
Constant * getAggregateElement(unsigned Elt) const
For aggregates (struct/array/vector) return the constant that corresponds to the specified element if...
static MDNode * getMostGenericTBAA(MDNode *A, MDNode *B)
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
uint64_t NextPowerOf2(uint64_t A)
NextPowerOf2 - 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.
uint64_t getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
const ElemTy & getOrInsertLeaderValue(const ElemTy &V)
getOrInsertLeaderValue - Return the leader for the specified value that is in the set...
const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Type * getType() const
All values are typed, get the type of this value.
Provides information about what library functions are available for the current target.
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
LLVM_NODISCARD T pop_back_val()
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.
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
Class to represent vector types.
Class for arbitrary precision integers.
bool isIntegerTy() const
True if this is an instance of IntegerType.
iterator_range< user_iterator > users()
unsigned getVectorNumElements() const
Value * getUniqueCastUse(Value *Ptr, Loop *Lp, Type *Ty)
If a value has only one user that is a CastInst, return it.
unsigned getGEPInductionOperand(const GetElementPtrInst *Gep)
Find the operand of the GEP that should be checked for consecutive stores.
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
This class represents an analyzed expression in the program.
Represents a single loop in the control flow graph.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
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.
static MDNode * getMostGenericFPMath(MDNode *A, MDNode *B)
Type * getResultElementType() const
LLVM_READONLY APFloat minnum(const APFloat &A, const APFloat &B)
Implements IEEE minNum semantics.
Instruction * propagateMetadata(Instruction *I, ArrayRef< Value * > VL)
Specifically, let Kinds = [MD_tbaa, MD_alias_scope, MD_noalias, MD_fpmath, MD_nontemporal].
gep_type_iterator gep_type_begin(const User *GEP)
bool isTriviallyVectorizable(Intrinsic::ID ID)
Identify if the intrinsic is trivially vectorizable.