40 #define DEBUG_TYPE "load-store-vectorizer"
41 STATISTIC(NumVectorInstructions,
"Number of vector accesses generated");
42 STATISTIC(NumScalarsVectorized,
"Number of scalar accesses vectorized");
47 static const unsigned StackAdjustedAlignment = 4;
63 : F(F), AA(AA), DT(DT), SE(SE), TTI(TTI),
64 DL(F.
getParent()->getDataLayout()), Builder(SE.getContext()) {}
73 unsigned getPointerAddressSpace(
Value *
I);
98 std::pair<BasicBlock::iterator, BasicBlock::iterator>
120 std::pair<InstrListMap, InstrListMap> collectInstructions(
BasicBlock *BB);
124 bool vectorizeChains(InstrListMap &Map);
140 bool accessIsMisaligned(
unsigned SzInBytes,
unsigned AddressSpace,
152 bool runOnFunction(
Function &
F)
override;
155 return "GPU Load and Store Vectorizer";
169 "Vectorize load and Store instructions",
false,
false)
178 char LoadStoreVectorizer::
ID = 0;
181 return new LoadStoreVectorizer();
191 bool LoadStoreVectorizer::runOnFunction(
Function &
F) {
193 if (skipFunction(F) || F.
hasFnAttribute(Attribute::NoImplicitFloat))
196 AliasAnalysis &AA = getAnalysis<AAResultsWrapperPass>().getAAResults();
197 DominatorTree &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree();
198 ScalarEvolution &SE = getAnalysis<ScalarEvolutionWrapperPass>().getSE();
200 getAnalysis<TargetTransformInfoWrapperPass>().getTTI(F);
202 Vectorizer V(F, AA, DT, SE, TTI);
207 bool Vectorizer::run() {
208 bool Changed =
false;
212 InstrListMap LoadRefs, StoreRefs;
213 std::tie(LoadRefs, StoreRefs) = collectInstructions(BB);
214 Changed |= vectorizeChains(LoadRefs);
215 Changed |= vectorizeChains(StoreRefs);
222 if (
LoadInst *LI = dyn_cast<LoadInst>(I))
224 if (
StoreInst *SI = dyn_cast<StoreInst>(I))
229 unsigned Vectorizer::getPointerAddressSpace(
Value *I) {
231 return L->getPointerAddressSpace();
232 if (
StoreInst *S = dyn_cast<StoreInst>(I))
233 return S->getPointerAddressSpace();
254 unsigned ASA = getPointerAddressSpace(A);
255 unsigned ASB = getPointerAddressSpace(B);
258 if (!PtrA || !PtrB || (ASA != ASB))
273 APInt OffsetA(PtrBitWidth, 0), OffsetB(PtrBitWidth, 0);
277 APInt OffsetDelta = OffsetB - OffsetA;
282 return OffsetDelta ==
Size;
307 for (
unsigned i = 0; i < FinalIndex; i++)
313 if (!OpA || !OpB || OpA->
getOpcode() != OpB->getOpcode() ||
314 OpA->
getType() != OpB->getType())
318 if (!isa<SExtInst>(OpA) && !isa<ZExtInst>(OpA))
321 bool Signed = isa<SExtInst>(OpA);
325 if (!OpA || !OpB || OpA->getType() != OpB->getType())
333 isa<ConstantInt>(OpB->getOperand(1)) &&
334 cast<ConstantInt>(OpB->getOperand(1))->getSExtValue() > 0) {
336 Safe = cast<BinaryOperator>(OpB)->hasNoSignedWrap();
338 Safe = cast<BinaryOperator>(OpB)->hasNoUnsignedWrap();
341 unsigned BitWidth = OpA->getType()->getScalarSizeInBits();
349 if (Known.countMaxTrailingOnes() < (BitWidth - 1))
360 return X2 == OffsetSCEVB;
369 while (!Worklist.
empty()) {
372 for (
int i = 0; i < NumOperands; i++) {
374 if (!IM || IM->
getOpcode() == Instruction::PHI)
382 if (!OBB.dominates(IM, I)) {
383 InstructionsToMove.insert(IM);
392 if (!InstructionsToMove.count(&*BBI))
401 std::pair<BasicBlock::iterator, BasicBlock::iterator>
408 unsigned NumFound = 0;
417 if (NumFound == Chain.
size()) {
424 return std::make_pair(FirstInstr, ++LastInstr);
431 assert(PtrOperand &&
"Instruction must have a pointer operand.");
445 unsigned ElementSizeBits) {
446 unsigned ElementSizeBytes = ElementSizeBits / 8;
447 unsigned SizeBytes = ElementSizeBytes * Chain.
size();
448 unsigned NumLeft = (SizeBytes - (SizeBytes % 4)) / ElementSizeBytes;
449 if (NumLeft == Chain.
size()) {
450 if ((NumLeft & 1) == 0)
454 }
else if (NumLeft == 0)
456 return std::make_pair(Chain.
slice(0, NumLeft), Chain.
slice(NumLeft));
465 bool IsLoadChain = isa<LoadInst>(Chain[0]);
469 assert(isa<LoadInst>(I) &&
470 "All elements of Chain must be loads, or all must be stores.");
472 assert(isa<StoreInst>(I) &&
473 "All elements of Chain must be loads, or all must be stores.");
478 if (isa<LoadInst>(I) || isa<StoreInst>(
I)) {
484 DEBUG(
dbgs() <<
"LSV: Found may-write/throw operation: " << I <<
'\n');
487 DEBUG(
dbgs() <<
"LSV: Found may-read/write/throw operation: " << I
496 unsigned ChainInstrIdx = 0;
499 for (
unsigned E = ChainInstrs.
size(); ChainInstrIdx <
E; ++ChainInstrIdx) {
500 Instruction *ChainInstr = ChainInstrs[ChainInstrIdx];
504 if (BarrierMemoryInstr && OBB.dominates(BarrierMemoryInstr, ChainInstr))
511 if (BarrierMemoryInstr && OBB.dominates(BarrierMemoryInstr, MemInstr))
514 if (isa<LoadInst>(MemInstr) && isa<LoadInst>(ChainInstr))
521 if (isa<StoreInst>(MemInstr) && isa<LoadInst>(ChainInstr) &&
522 OBB.dominates(ChainInstr, MemInstr))
526 if (isa<LoadInst>(MemInstr) && isa<StoreInst>(ChainInstr) &&
527 OBB.dominates(MemInstr, ChainInstr))
533 dbgs() <<
"LSV: Found alias:\n"
534 " Aliasing instruction and pointer:\n"
535 <<
" " << *MemInstr <<
'\n'
537 <<
" Aliased instruction and pointer:\n"
538 <<
" " << *ChainInstr <<
'\n'
543 BarrierMemoryInstr = MemInstr;
551 if (IsLoadChain && BarrierMemoryInstr) {
553 assert(OBB.dominates(BarrierMemoryInstr, ChainInstr));
563 ChainInstrs.
begin(), ChainInstrs.
begin() + ChainInstrIdx);
564 unsigned ChainIdx = 0;
565 for (
unsigned ChainLen = Chain.size(); ChainIdx < ChainLen; ++ChainIdx) {
566 if (!VectorizableChainInstrs.count(Chain[ChainIdx]))
569 return Chain.slice(0, ChainIdx);
572 std::pair<InstrListMap, InstrListMap>
573 Vectorizer::collectInstructions(
BasicBlock *BB) {
574 InstrListMap LoadRefs;
575 InstrListMap StoreRefs;
581 if (
LoadInst *LI = dyn_cast<LoadInst>(&I)) {
604 if (TySize > VecRegSize / 2)
610 return EEI && isa<ConstantInt>(EEI->
getOperand(1));
616 LoadRefs[ObjPtr].push_back(LI);
618 }
else if (
StoreInst *SI = dyn_cast<StoreInst>(&I)) {
639 if (TySize > VecRegSize / 2)
644 return EEI && isa<ConstantInt>(EEI->
getOperand(1));
650 StoreRefs[ObjPtr].push_back(SI);
654 return {LoadRefs, StoreRefs};
657 bool Vectorizer::vectorizeChains(InstrListMap &Map) {
658 bool Changed =
false;
660 for (
const std::pair<Value *, InstrList> &Chain : Map) {
661 unsigned Size = Chain.second.size();
665 DEBUG(
dbgs() <<
"LSV: Analyzing a chain of length " << Size <<
".\n");
668 for (
unsigned CI = 0, CE = Size; CI <
CE; CI += 64) {
669 unsigned Len = std::min<unsigned>(CE - CI, 64);
671 Changed |= vectorizeInstructions(Chunk);
679 DEBUG(
dbgs() <<
"LSV: Vectorizing " << Instrs.
size() <<
" instructions.\n");
681 int ConsecutiveChain[64];
685 for (
int i = 0, e = Instrs.
size(); i < e; ++i) {
686 ConsecutiveChain[i] = -1;
687 for (
int j = e - 1; j >= 0; --j) {
692 if (ConsecutiveChain[i] != -1) {
693 int CurDistance =
std::abs(ConsecutiveChain[i] - i);
694 int NewDistance =
std::abs(ConsecutiveChain[i] - j);
695 if (j < i || NewDistance > CurDistance)
701 ConsecutiveChain[i] = j;
706 bool Changed =
false;
709 for (
int Head : Heads) {
710 if (InstructionsProcessed.
count(Instrs[Head]))
712 bool LongerChainExists =
false;
713 for (
unsigned TIt = 0; TIt < Tails.size(); TIt++)
714 if (Head == Tails[TIt] &&
715 !InstructionsProcessed.
count(Instrs[Heads[TIt]])) {
716 LongerChainExists =
true;
719 if (LongerChainExists)
727 if (InstructionsProcessed.
count(Instrs[I]))
731 I = ConsecutiveChain[
I];
734 bool Vectorized =
false;
735 if (isa<LoadInst>(*Operands.
begin()))
736 Vectorized = vectorizeLoadChain(Operands, &InstructionsProcessed);
738 Vectorized = vectorizeStoreChain(Operands, &InstructionsProcessed);
740 Changed |= Vectorized;
746 bool Vectorizer::vectorizeStoreChain(
749 StoreInst *S0 = cast<StoreInst>(Chain[0]);
754 StoreTy = cast<StoreInst>(
I)->getValueOperand()->getType();
755 if (StoreTy->isIntOrIntVectorTy())
758 if (StoreTy->isPtrOrPtrVectorTy()) {
768 unsigned VF = VecRegSize / Sz;
769 unsigned ChainSize = Chain.size();
773 InstructionsProcessed->
insert(Chain.begin(), Chain.end());
778 if (NewChain.
empty()) {
780 InstructionsProcessed->
insert(Chain.begin(), Chain.end());
783 if (NewChain.
size() == 1) {
791 ChainSize = Chain.size();
795 unsigned EltSzInBytes = Sz / 8;
796 unsigned SzInBytes = EltSzInBytes * ChainSize;
798 auto Chains = splitOddVectorElts(Chain, Sz);
799 return vectorizeStoreChain(Chains.first, InstructionsProcessed) |
800 vectorizeStoreChain(Chains.second, InstructionsProcessed);
814 if (ChainSize > VF || (VF != TargetVF && TargetVF < ChainSize)) {
815 DEBUG(
dbgs() <<
"LSV: Chain doesn't match with the vector factor."
816 " Creating two separate arrays.\n");
817 return vectorizeStoreChain(Chain.slice(0, TargetVF),
818 InstructionsProcessed) |
819 vectorizeStoreChain(Chain.slice(TargetVF), InstructionsProcessed);
823 dbgs() <<
"LSV: Stores to vectorize:\n";
825 dbgs() <<
" " << *I <<
"\n";
830 InstructionsProcessed->
insert(Chain.begin(), Chain.end());
833 if (accessIsMisaligned(SzInBytes, AS, Alignment)) {
838 StackAdjustedAlignment,
839 DL, S0,
nullptr, &DT);
840 if (NewAlign < StackAdjustedAlignment)
845 std::tie(First, Last) = getBoundaryInstrs(Chain);
846 Builder.SetInsertPoint(&*Last);
852 for (
unsigned I = 0, E = Chain.size(); I !=
E; ++
I) {
855 unsigned NewIdx = J + I * VecWidth;
857 Builder.getInt32(J));
859 Extract = Builder.CreateBitCast(Extract, StoreTy->getScalarType());
862 Builder.CreateInsertElement(Vec, Extract, Builder.getInt32(NewIdx));
867 for (
unsigned I = 0, E = Chain.size(); I !=
E; ++
I) {
870 if (Extract->getType() != StoreTy->getScalarType())
872 Builder.CreateBitOrPointerCast(Extract, StoreTy->getScalarType());
875 Builder.CreateInsertElement(Vec, Extract, Builder.getInt32(I));
883 Builder.CreateStore(Vec, Builder.CreateBitCast(S0->getPointerOperand(),
884 VecTy->getPointerTo(AS))));
888 eraseInstructions(Chain);
889 ++NumVectorInstructions;
890 NumScalarsVectorized += Chain.size();
894 bool Vectorizer::vectorizeLoadChain(
897 LoadInst *L0 = cast<LoadInst>(Chain[0]);
901 for (
const auto &V : Chain) {
902 LoadTy = cast<LoadInst>(V)->
getType();
903 if (LoadTy->isIntOrIntVectorTy())
906 if (LoadTy->isPtrOrPtrVectorTy()) {
908 DL.getTypeSizeInBits(LoadTy));
913 unsigned Sz = DL.getTypeSizeInBits(LoadTy);
916 unsigned VF = VecRegSize / Sz;
917 unsigned ChainSize = Chain.size();
921 InstructionsProcessed->
insert(Chain.begin(), Chain.end());
926 if (NewChain.
empty()) {
928 InstructionsProcessed->
insert(Chain.begin(), Chain.end());
931 if (NewChain.
size() == 1) {
939 ChainSize = Chain.size();
943 unsigned EltSzInBytes = Sz / 8;
944 unsigned SzInBytes = EltSzInBytes * ChainSize;
946 auto Chains = splitOddVectorElts(Chain, Sz);
947 return vectorizeLoadChain(Chains.first, InstructionsProcessed) |
948 vectorizeLoadChain(Chains.second, InstructionsProcessed);
962 if (ChainSize > VF || (VF != TargetVF && TargetVF < ChainSize)) {
963 DEBUG(
dbgs() <<
"LSV: Chain doesn't match with the vector factor."
964 " Creating two separate arrays.\n");
965 return vectorizeLoadChain(Chain.slice(0, TargetVF), InstructionsProcessed) |
966 vectorizeLoadChain(Chain.slice(TargetVF), InstructionsProcessed);
971 InstructionsProcessed->
insert(Chain.begin(), Chain.end());
974 if (accessIsMisaligned(SzInBytes, AS, Alignment)) {
979 StackAdjustedAlignment,
980 DL, L0,
nullptr, &DT);
981 if (NewAlign < StackAdjustedAlignment)
984 Alignment = NewAlign;
988 dbgs() <<
"LSV: Loads to vectorize:\n";
997 std::tie(First, Last) = getBoundaryInstrs(Chain);
998 Builder.SetInsertPoint(&*First);
1001 Builder.CreateBitCast(L0->getPointerOperand(), VecTy->getPointerTo(AS));
1004 LoadInst *LI = cast<LoadInst>(Builder.CreateLoad(Bitcast));
1012 for (
unsigned I = 0, E = Chain.size(); I !=
E; ++
I) {
1013 for (
auto Use : Chain[I]->
users()) {
1017 unsigned Idx = cast<ConstantInt>(UI->
getOperand(1))->getZExtValue();
1018 unsigned NewIdx = Idx + I * VecWidth;
1019 Value *V = Builder.CreateExtractElement(LI, Builder.getInt32(NewIdx),
1022 V = Builder.CreateBitCast(V, UI->
getType());
1032 if (
Instruction *BitcastInst = dyn_cast<Instruction>(Bitcast))
1033 reorder(BitcastInst);
1035 for (
auto I : InstrsToErase)
1036 I->eraseFromParent();
1038 for (
unsigned I = 0, E = Chain.size(); I !=
E; ++
I) {
1041 Builder.CreateExtractElement(LI, Builder.getInt32(I), CV->
getName());
1043 V = Builder.CreateBitOrPointerCast(V, CV->
getType());
1050 if (
Instruction *BitcastInst = dyn_cast<Instruction>(Bitcast))
1051 reorder(BitcastInst);
1054 eraseInstructions(Chain);
1056 ++NumVectorInstructions;
1057 NumScalarsVectorized += Chain.size();
1061 bool Vectorizer::accessIsMisaligned(
unsigned SzInBytes,
unsigned AddressSpace,
1062 unsigned Alignment) {
1063 if (Alignment % SzInBytes == 0)
1070 DEBUG(
dbgs() <<
"LSV: Target said misaligned is allowed? " << Allows
1071 <<
" and fast? " << Fast <<
"\n";);
1072 return !Allows || !
Fast;
Legacy wrapper pass to provide the GlobalsAAResult object.
Pass interface - Implemented by all 'passes'.
Value * getValueOperand()
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
void push_back(const T &Elt)
A parsed version of the target data layout string in and methods for querying it. ...
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
unsigned getOrEnforceKnownAlignment(Value *V, unsigned PrefAlign, const DataLayout &DL, const Instruction *CxtI=nullptr, AssumptionCache *AC=nullptr, const DominatorTree *DT=nullptr)
Try to ensure that the alignment of V is at least PrefAlign bytes.
const SCEV * getConstant(ConstantInt *V)
STATISTIC(NumFunctions,"Total number of functions")
const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs, and aliases.
const T & front() const
front - Get the first element.
INITIALIZE_PASS_BEGIN(LoadStoreVectorizer, DEBUG_TYPE,"Vectorize load and Store instructions", false, false) INITIALIZE_PASS_END(LoadStoreVectorizer
unsigned getNumOperands() const
bool isNoAlias(const MemoryLocation &LocA, const MemoryLocation &LocB)
A trivial helper function to check to see if the specified pointers are no-alias. ...
The main scalar evolution driver.
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
This class implements a map that also provides access to all stored values in a deterministic order...
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly...
An instruction for reading from memory.
Type * getPointerElementType() const
StringRef getName() const
Return a constant reference to the value's name.
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...
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
static uint32_t getAlignment(const MCSectionCOFF &Sec)
static Value * getPointerOperand(Instruction &Inst)
A Use represents the edge between a Value definition and its users.
Pass * createLoadStoreVectorizerPass()
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
Windows NT (Windows on ARM)
LLVM_NODISCARD bool empty() const
unsigned getPointerAddressSpace() const
Returns the address space of the pointer operand.
void initializeLoadStoreVectorizerPass(PassRegistry &)
static bool isValidElementType(Type *ElemTy)
Return true if the specified type is valid as a element type.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
An instruction for storing to memory.
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
size_t size() const
size - Get the array size.
bool mayReadOrWriteMemory() const
Return true if this instruction may read or write memory.
bool isConsecutiveAccess(Value *A, Value *B, const DataLayout &DL, ScalarEvolution &SE, bool CheckType=true)
Returns true if the memory operations A and B are consecutive.
an instruction for type-safe pointer arithmetic to access elements of arrays and structs ...
static MemoryLocation get(const LoadInst *LI)
Return a location with information about the memory reference by the given instruction.
unsigned getAlignment() const
Return the alignment of the access that is being performed.
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
void insertBefore(Instruction *InsertPos)
Insert an unlinked instruction into a basic block immediately before the specified instruction...
LLVM Basic Block Representation.
The instances of the Type class are immutable: once they are created, they are never changed...
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
Represent the analysis usage information of a pass.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang","erlang-compatible garbage collector")
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE,"Assign register bank of generic virtual registers", false, false) RegBankSelect
uint64_t getNumElements() const
FunctionPass class - This class is used to implement most global optimizations.
Value * getOperand(unsigned i) const
Value * getPointerOperand()
iterator_range< po_iterator< T > > post_order(const T &G)
self_iterator getIterator()
Vectorize load and store false
bool empty() const
empty - Check if the array is empty.
void setAlignment(unsigned Align)
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
static wasm::ValType getType(const TargetRegisterClass *RC)
Value * GetUnderlyingObject(Value *V, const DataLayout &DL, unsigned MaxLookup=6)
This method strips off any GEP address adjustments and pointer casts from the specified value...
bool mayWriteToMemory() const
Return true if this instruction may modify memory.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
unsigned getABITypeAlignment(Type *Ty) const
Returns the minimum ABI-required alignment for the specified type.
Iterator for intrusive lists based on ilist_node.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
Legacy wrapper pass to provide the SCEVAAResult object.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Module.h This file contains the declarations for the Module class.
Type * getType() const
All values are typed, get the type of this value.
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
LLVM_NODISCARD T pop_back_val()
static IntegerType * getIntNTy(LLVMContext &C, unsigned N)
void setPreservesCFG()
This function should be called by the pass, iff they do not:
unsigned getPointerAddressSpace() const
Returns the address space of the pointer operand.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Class to represent vector types.
Class for arbitrary precision integers.
iterator_range< user_iterator > users()
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
void removeFromParent()
This method unlinks 'this' from the containing basic block, but does not delete it.
bool mayThrow() const
Return true if this instruction may throw an exception.
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
This class represents an analyzed expression in the program.
unsigned getAlignment() const
Return the alignment of the access that is being performed.
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
APFloat abs(APFloat X)
Returns the absolute value of the argument.
unsigned getPointerSizeInBits(unsigned AS=0) const
Layout pointer size, in bits FIXME: The defaults need to be removed once all of the backends/clients ...
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
Fast - This calling convention attempts to make calls as fast as possible (e.g.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
uint64_t getTypeStoreSize(Type *Ty) const
Returns the maximum number of bytes that may be overwritten by storing the specified type...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
void setAlignment(unsigned Align)
const SCEV * getSCEV(Value *V)
Return a SCEV expression for the full generality of the specified expression.
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
static VectorType * get(Type *ElementType, unsigned NumElements)
This static method is the primary way to construct an VectorType.
static const Function * getParent(const Value *V)
uint64_t getTypeSizeInBits(Type *Ty) const
Size examples:
StringRef - Represent a constant reference to a string, i.e.
inst_range instructions(Function *F)
Legacy analysis pass which computes a DominatorTree.
const SCEV * getAddExpr(SmallVectorImpl< const SCEV * > &Ops, SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap, unsigned Depth=0)
Get a canonical add expression, or something simpler if possible.
A wrapper pass to provide the legacy pass manager access to a suitably prepared AAResults object...
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
Value * getPointerOperand()
void computeKnownBits(const Value *V, KnownBits &Known, const DataLayout &DL, unsigned Depth=0, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr, OptimizationRemarkEmitter *ORE=nullptr)
Determine which bits of V are known to be either zero or one and return them in the KnownZero/KnownOn...
const BasicBlock * getParent() const
const Value * stripAndAccumulateInBoundsConstantOffsets(const DataLayout &DL, APInt &Offset) const
Accumulate offsets from stripInBoundsConstantOffsets().
LLVMContext & getContext() const
Get the global data context.
Instruction * propagateMetadata(Instruction *I, ArrayRef< Value * > VL)
Specifically, let Kinds = [MD_tbaa, MD_alias_scope, MD_noalias, MD_fpmath, MD_nontemporal].
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.