90 #define DEBUG_TYPE "load-store-vectorizer" 92 STATISTIC(NumVectorInstructions,
"Number of vector accesses generated");
93 STATISTIC(NumScalarsVectorized,
"Number of scalar accesses vectorized");
107 using ChainID =
const Value *;
123 :
F(F), AA(AA), DT(DT), SE(SE), TTI(TTI),
129 unsigned getPointerAddressSpace(
Value *
I);
150 bool areConsecutivePointers(
Value *PtrA,
Value *PtrB,
const APInt &PtrDelta,
151 unsigned Depth = 0)
const;
152 bool lookThroughComplexAddresses(
Value *PtrA,
Value *PtrB,
APInt PtrDelta,
153 unsigned Depth)
const;
154 bool lookThroughSelects(
Value *PtrA,
Value *PtrB,
const APInt &PtrDelta,
155 unsigned Depth)
const;
162 std::pair<BasicBlock::iterator, BasicBlock::iterator>
184 std::pair<InstrListMap, InstrListMap> collectInstructions(
BasicBlock *BB);
188 bool vectorizeChains(InstrListMap &Map);
204 bool accessIsMisaligned(
unsigned SzInBytes,
unsigned AddressSpace,
219 return "GPU Load and Store Vectorizer";
236 "Vectorize load and Store instructions",
false,
false)
246 return new LoadStoreVectorizer();
258 if (skipFunction(F) || F.
hasFnAttribute(Attribute::NoImplicitFloat))
261 AliasAnalysis &AA = getAnalysis<AAResultsWrapperPass>().getAAResults();
262 DominatorTree &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree();
263 ScalarEvolution &SE = getAnalysis<ScalarEvolutionWrapperPass>().getSE();
265 getAnalysis<TargetTransformInfoWrapperPass>().getTTI(F);
267 Vectorizer V(F, AA, DT, SE, TTI);
272 bool Vectorizer::run() {
273 bool Changed =
false;
277 InstrListMap LoadRefs, StoreRefs;
278 std::tie(LoadRefs, StoreRefs) = collectInstructions(BB);
279 Changed |= vectorizeChains(LoadRefs);
280 Changed |= vectorizeChains(StoreRefs);
286 unsigned Vectorizer::getPointerAddressSpace(
Value *
I) {
287 if (
LoadInst *L = dyn_cast<LoadInst>(I))
288 return L->getPointerAddressSpace();
289 if (
StoreInst *S = dyn_cast<StoreInst>(I))
290 return S->getPointerAddressSpace();
298 unsigned ASA = getPointerAddressSpace(A);
299 unsigned ASB = getPointerAddressSpace(B);
302 if (!PtrA || !PtrB || (ASA != ASB))
310 DL.getTypeStoreSize(PtrATy) != DL.getTypeStoreSize(PtrBTy) ||
315 unsigned PtrBitWidth = DL.getPointerSizeInBits(ASA);
316 APInt Size(PtrBitWidth, DL.getTypeStoreSize(PtrATy));
318 return areConsecutivePointers(PtrA, PtrB,
Size);
321 bool Vectorizer::areConsecutivePointers(
Value *PtrA,
Value *PtrB,
322 const APInt &PtrDelta,
323 unsigned Depth)
const {
324 unsigned PtrBitWidth = DL.getPointerTypeSizeInBits(PtrA->
getType());
325 APInt OffsetA(PtrBitWidth, 0);
326 APInt OffsetB(PtrBitWidth, 0);
330 APInt OffsetDelta = OffsetB - OffsetA;
335 return OffsetDelta == PtrDelta;
339 APInt BaseDelta = PtrDelta - OffsetDelta;
342 const SCEV *PtrSCEVA = SE.getSCEV(PtrA);
343 const SCEV *PtrSCEVB = SE.getSCEV(PtrB);
344 const SCEV *
C = SE.getConstant(BaseDelta);
345 const SCEV *
X = SE.getAddExpr(PtrSCEVA, C);
353 const SCEV *Dist = SE.getMinusSCEV(PtrSCEVB, PtrSCEVA);
360 return lookThroughComplexAddresses(PtrA, PtrB, BaseDelta, Depth);
363 bool Vectorizer::lookThroughComplexAddresses(
Value *PtrA,
Value *PtrB,
365 unsigned Depth)
const {
369 return lookThroughSelects(PtrA, PtrB, PtrDelta, Depth);
373 if (GEPA->getNumOperands() != GEPB->getNumOperands() ||
374 GEPA->getPointerOperand() != GEPB->getPointerOperand())
378 for (
unsigned I = 0,
E = GEPA->getNumIndices() - 1; I <
E; ++
I) {
387 if (!OpA || !OpB || OpA->
getOpcode() != OpB->getOpcode() ||
388 OpA->
getType() != OpB->getType())
398 if (PtrDelta.
urem(Stride) != 0)
404 if (!isa<SExtInst>(OpA) && !isa<ZExtInst>(OpA))
407 bool Signed = isa<SExtInst>(OpA);
412 if (!OpB || ValA->getType() != OpB->getType())
420 isa<ConstantInt>(OpB->getOperand(1)) &&
421 IdxDiff.
sle(cast<ConstantInt>(OpB->getOperand(1))->getSExtValue())) {
423 Safe = cast<BinaryOperator>(OpB)->hasNoSignedWrap();
425 Safe = cast<BinaryOperator>(OpB)->hasNoUnsignedWrap();
428 unsigned BitWidth = ValA->getType()->getScalarSizeInBits();
442 BitsAllowedToBeSet.
clearBit(BitWidth - 1);
443 if (BitsAllowedToBeSet.
ult(IdxDiff))
447 const SCEV *OffsetSCEVA = SE.getSCEV(ValA);
448 const SCEV *OffsetSCEVB = SE.getSCEV(OpB);
449 const SCEV *
C = SE.getConstant(IdxDiff.
trunc(BitWidth));
450 const SCEV *
X = SE.getAddExpr(OffsetSCEVA, C);
451 return X == OffsetSCEVB;
454 bool Vectorizer::lookThroughSelects(
Value *PtrA,
Value *PtrB,
455 const APInt &PtrDelta,
456 unsigned Depth)
const {
460 if (
auto *SelectA = dyn_cast<SelectInst>(PtrA)) {
461 if (
auto *SelectB = dyn_cast<SelectInst>(PtrB)) {
462 return SelectA->getCondition() == SelectB->getCondition() &&
463 areConsecutivePointers(SelectA->getTrueValue(),
464 SelectB->getTrueValue(), PtrDelta,
Depth) &&
465 areConsecutivePointers(SelectA->getFalseValue(),
466 SelectB->getFalseValue(), PtrDelta,
Depth);
478 while (!Worklist.
empty()) {
481 for (
int i = 0; i < NumOperands; i++) {
483 if (!IM || IM->
getOpcode() == Instruction::PHI)
491 if (!OBB.dominates(IM, I)) {
492 InstructionsToMove.insert(IM);
501 if (!InstructionsToMove.count(&*BBI))
510 std::pair<BasicBlock::iterator, BasicBlock::iterator>
517 unsigned NumFound = 0;
526 if (NumFound == Chain.
size()) {
533 return std::make_pair(FirstInstr, ++LastInstr);
540 assert(PtrOperand &&
"Instruction must have a pointer operand.");
554 unsigned ElementSizeBits) {
555 unsigned ElementSizeBytes = ElementSizeBits / 8;
556 unsigned SizeBytes = ElementSizeBytes * Chain.
size();
557 unsigned NumLeft = (SizeBytes - (SizeBytes % 4)) / ElementSizeBytes;
558 if (NumLeft == Chain.
size()) {
559 if ((NumLeft & 1) == 0)
563 }
else if (NumLeft == 0)
565 return std::make_pair(Chain.
slice(0, NumLeft), Chain.
slice(NumLeft));
574 bool IsLoadChain = isa<LoadInst>(Chain[0]);
578 assert(isa<LoadInst>(I) &&
579 "All elements of Chain must be loads, or all must be stores.");
581 assert(isa<StoreInst>(I) &&
582 "All elements of Chain must be loads, or all must be stores.");
587 if (isa<LoadInst>(I) || isa<StoreInst>(
I)) {
592 }
else if (isa<IntrinsicInst>(&I) &&
594 Intrinsic::sideeffect) {
597 LLVM_DEBUG(
dbgs() <<
"LSV: Found may-write/throw operation: " << I
601 LLVM_DEBUG(
dbgs() <<
"LSV: Found may-read/write/throw operation: " << I
610 unsigned ChainInstrIdx = 0;
613 for (
unsigned E = ChainInstrs.
size(); ChainInstrIdx <
E; ++ChainInstrIdx) {
614 Instruction *ChainInstr = ChainInstrs[ChainInstrIdx];
618 if (BarrierMemoryInstr && OBB.
dominates(BarrierMemoryInstr, ChainInstr))
625 if (BarrierMemoryInstr && OBB.
dominates(BarrierMemoryInstr, MemInstr))
630 if (MemLoad && ChainLoad)
635 auto IsInvariantLoad = [](
const LoadInst *LI) ->
bool {
643 if (isa<StoreInst>(MemInstr) && ChainLoad &&
644 (IsInvariantLoad(ChainLoad) || OBB.
dominates(ChainLoad, MemInstr)))
648 if (MemLoad && isa<StoreInst>(ChainInstr) &&
649 (IsInvariantLoad(MemLoad) || OBB.
dominates(MemLoad, ChainInstr)))
655 dbgs() <<
"LSV: Found alias:\n" 656 " Aliasing instruction and pointer:\n" 657 <<
" " << *MemInstr <<
'\n' 659 <<
" Aliased instruction and pointer:\n" 660 <<
" " << *ChainInstr <<
'\n' 665 BarrierMemoryInstr = MemInstr;
673 if (IsLoadChain && BarrierMemoryInstr) {
685 ChainInstrs.
begin(), ChainInstrs.
begin() + ChainInstrIdx);
686 unsigned ChainIdx = 0;
687 for (
unsigned ChainLen = Chain.
size(); ChainIdx < ChainLen; ++ChainIdx) {
688 if (!VectorizableChainInstrs.count(Chain[ChainIdx]))
691 return Chain.
slice(0, ChainIdx);
696 if (
const auto *Sel = dyn_cast<SelectInst>(ObjPtr)) {
703 return Sel->getCondition();
708 std::pair<InstrListMap, InstrListMap>
709 Vectorizer::collectInstructions(
BasicBlock *BB) {
710 InstrListMap LoadRefs;
711 InstrListMap StoreRefs;
717 if (
LoadInst *LI = dyn_cast<LoadInst>(&I)) {
722 if (!TTI.isLegalToVectorizeLoad(LI))
725 Type *Ty = LI->getType();
731 unsigned TySize = DL.getTypeSizeInBits(Ty);
732 if ((TySize % 8) != 0)
742 Value *
Ptr = LI->getPointerOperand();
744 unsigned VecRegSize = TTI.getLoadStoreVecRegBitWidth(AS);
746 unsigned VF = VecRegSize / TySize;
750 if (TySize > VecRegSize / 2 ||
751 (VecTy && TTI.getLoadVectorFactor(VF, TySize, TySize / 8, VecTy) == 0))
757 return EEI && isa<ConstantInt>(EEI->
getOperand(1));
763 LoadRefs[
ID].push_back(LI);
764 }
else if (
StoreInst *
SI = dyn_cast<StoreInst>(&I)) {
769 if (!TTI.isLegalToVectorizeStore(
SI))
772 Type *Ty =
SI->getValueOperand()->getType();
785 unsigned TySize = DL.getTypeSizeInBits(Ty);
786 if ((TySize % 8) != 0)
791 unsigned VecRegSize = TTI.getLoadStoreVecRegBitWidth(AS);
793 unsigned VF = VecRegSize / TySize;
797 if (TySize > VecRegSize / 2 ||
798 (VecTy && TTI.getStoreVectorFactor(VF, TySize, TySize / 8, VecTy) == 0))
803 return EEI && isa<ConstantInt>(EEI->
getOperand(1));
809 StoreRefs[
ID].push_back(
SI);
813 return {LoadRefs, StoreRefs};
816 bool Vectorizer::vectorizeChains(InstrListMap &Map) {
817 bool Changed =
false;
819 for (
const std::pair<ChainID, InstrList> &Chain : Map) {
820 unsigned Size = Chain.second.
size();
824 LLVM_DEBUG(
dbgs() <<
"LSV: Analyzing a chain of length " << Size <<
".\n");
827 for (
unsigned CI = 0, CE = Size; CI < CE; CI += 64) {
828 unsigned Len = std::min<unsigned>(CE - CI, 64);
830 Changed |= vectorizeInstructions(Chunk);
839 <<
" instructions.\n");
841 int ConsecutiveChain[64];
845 for (
int i = 0, e = Instrs.
size(); i < e; ++i) {
846 ConsecutiveChain[i] = -1;
847 for (
int j = e - 1; j >= 0; --j) {
852 if (ConsecutiveChain[i] != -1) {
853 int CurDistance =
std::abs(ConsecutiveChain[i] - i);
854 int NewDistance =
std::abs(ConsecutiveChain[i] - j);
855 if (j < i || NewDistance > CurDistance)
861 ConsecutiveChain[i] = j;
866 bool Changed =
false;
869 for (
int Head : Heads) {
870 if (InstructionsProcessed.
count(Instrs[Head]))
872 bool LongerChainExists =
false;
873 for (
unsigned TIt = 0; TIt < Tails.size(); TIt++)
874 if (Head == Tails[TIt] &&
875 !InstructionsProcessed.
count(Instrs[Heads[TIt]])) {
876 LongerChainExists =
true;
879 if (LongerChainExists)
887 if (InstructionsProcessed.
count(Instrs[I]))
891 I = ConsecutiveChain[
I];
894 bool Vectorized =
false;
895 if (isa<LoadInst>(*Operands.
begin()))
896 Vectorized = vectorizeLoadChain(Operands, &InstructionsProcessed);
898 Vectorized = vectorizeStoreChain(Operands, &InstructionsProcessed);
900 Changed |= Vectorized;
906 bool Vectorizer::vectorizeStoreChain(
909 StoreInst *S0 = cast<StoreInst>(Chain[0]);
914 StoreTy = cast<StoreInst>(
I)->getValueOperand()->getType();
915 if (StoreTy->isIntOrIntVectorTy())
918 if (StoreTy->isPtrOrPtrVectorTy()) {
920 DL.getTypeSizeInBits(StoreTy));
925 unsigned Sz = DL.getTypeSizeInBits(StoreTy);
927 unsigned VecRegSize = TTI.getLoadStoreVecRegBitWidth(AS);
928 unsigned VF = VecRegSize / Sz;
929 unsigned ChainSize = Chain.size();
933 InstructionsProcessed->
insert(Chain.begin(), Chain.end());
938 if (NewChain.
empty()) {
940 InstructionsProcessed->
insert(Chain.begin(), Chain.end());
943 if (NewChain.
size() == 1) {
951 ChainSize = Chain.size();
955 unsigned EltSzInBytes = Sz / 8;
956 unsigned SzInBytes = EltSzInBytes * ChainSize;
957 if (!TTI.isLegalToVectorizeStoreChain(SzInBytes, Alignment, AS)) {
958 auto Chains = splitOddVectorElts(Chain, Sz);
959 return vectorizeStoreChain(Chains.first, InstructionsProcessed) |
960 vectorizeStoreChain(Chains.second, InstructionsProcessed);
973 unsigned TargetVF = TTI.getStoreVectorFactor(VF, Sz, SzInBytes, VecTy);
974 if (ChainSize > VF || (VF != TargetVF && TargetVF < ChainSize)) {
975 LLVM_DEBUG(
dbgs() <<
"LSV: Chain doesn't match with the vector factor." 976 " Creating two separate arrays.\n");
977 return vectorizeStoreChain(Chain.slice(0, TargetVF),
978 InstructionsProcessed) |
979 vectorizeStoreChain(Chain.slice(TargetVF), InstructionsProcessed);
983 dbgs() <<
"LSV: Stores to vectorize:\n";
985 dbgs() <<
" " << *I <<
"\n";
990 InstructionsProcessed->
insert(Chain.begin(), Chain.end());
993 if (accessIsMisaligned(SzInBytes, AS, Alignment)) {
999 DL, S0,
nullptr, &DT);
1000 if (NewAlign < StackAdjustedAlignment)
1005 std::tie(First, Last) = getBoundaryInstrs(Chain);
1006 Builder.SetInsertPoint(&*Last);
1012 for (
unsigned I = 0,
E = Chain.size(); I !=
E; ++
I) {
1015 unsigned NewIdx = J + I * VecWidth;
1017 Builder.getInt32(J));
1019 Extract = Builder.CreateBitCast(Extract, StoreTy->getScalarType());
1022 Builder.CreateInsertElement(Vec, Extract, Builder.getInt32(NewIdx));
1027 for (
unsigned I = 0,
E = Chain.size(); I !=
E; ++
I) {
1030 if (Extract->getType() != StoreTy->getScalarType())
1032 Builder.CreateBitOrPointerCast(Extract, StoreTy->getScalarType());
1035 Builder.CreateInsertElement(Vec, Extract, Builder.getInt32(I));
1044 VecTy->getPointerTo(AS))));
1048 eraseInstructions(Chain);
1049 ++NumVectorInstructions;
1050 NumScalarsVectorized += Chain.size();
1054 bool Vectorizer::vectorizeLoadChain(
1057 LoadInst *L0 = cast<LoadInst>(Chain[0]);
1061 for (
const auto &V : Chain) {
1062 LoadTy = cast<LoadInst>(V)->
getType();
1063 if (LoadTy->isIntOrIntVectorTy())
1066 if (LoadTy->isPtrOrPtrVectorTy()) {
1068 DL.getTypeSizeInBits(LoadTy));
1073 unsigned Sz = DL.getTypeSizeInBits(LoadTy);
1075 unsigned VecRegSize = TTI.getLoadStoreVecRegBitWidth(AS);
1076 unsigned VF = VecRegSize / Sz;
1077 unsigned ChainSize = Chain.size();
1081 InstructionsProcessed->
insert(Chain.begin(), Chain.end());
1086 if (NewChain.
empty()) {
1088 InstructionsProcessed->
insert(Chain.begin(), Chain.end());
1091 if (NewChain.
size() == 1) {
1099 ChainSize = Chain.size();
1103 unsigned EltSzInBytes = Sz / 8;
1104 unsigned SzInBytes = EltSzInBytes * ChainSize;
1105 if (!TTI.isLegalToVectorizeLoadChain(SzInBytes, Alignment, AS)) {
1106 auto Chains = splitOddVectorElts(Chain, Sz);
1107 return vectorizeLoadChain(Chains.first, InstructionsProcessed) |
1108 vectorizeLoadChain(Chains.second, InstructionsProcessed);
1121 unsigned TargetVF = TTI.getLoadVectorFactor(VF, Sz, SzInBytes, VecTy);
1122 if (ChainSize > VF || (VF != TargetVF && TargetVF < ChainSize)) {
1123 LLVM_DEBUG(
dbgs() <<
"LSV: Chain doesn't match with the vector factor." 1124 " Creating two separate arrays.\n");
1125 return vectorizeLoadChain(Chain.slice(0, TargetVF), InstructionsProcessed) |
1126 vectorizeLoadChain(Chain.slice(TargetVF), InstructionsProcessed);
1131 InstructionsProcessed->
insert(Chain.begin(), Chain.end());
1134 if (accessIsMisaligned(SzInBytes, AS, Alignment)) {
1140 DL, L0,
nullptr, &DT);
1141 if (NewAlign < StackAdjustedAlignment)
1144 Alignment = NewAlign;
1148 dbgs() <<
"LSV: Loads to vectorize:\n";
1157 std::tie(First, Last) = getBoundaryInstrs(Chain);
1158 Builder.SetInsertPoint(&*First);
1164 LoadInst *LI = cast<LoadInst>(Builder.CreateLoad(Bitcast));
1172 for (
unsigned I = 0,
E = Chain.size(); I !=
E; ++
I) {
1173 for (
auto Use : Chain[I]->
users()) {
1177 unsigned Idx = cast<ConstantInt>(UI->
getOperand(1))->getZExtValue();
1178 unsigned NewIdx = Idx + I * VecWidth;
1179 Value *V = Builder.CreateExtractElement(LI, Builder.getInt32(NewIdx),
1182 V = Builder.CreateBitCast(V, UI->
getType());
1192 if (
Instruction *BitcastInst = dyn_cast<Instruction>(Bitcast))
1193 reorder(BitcastInst);
1195 for (
auto I : InstrsToErase)
1198 for (
unsigned I = 0,
E = Chain.size(); I !=
E; ++
I) {
1201 Builder.CreateExtractElement(LI, Builder.getInt32(I), CV->
getName());
1203 V = Builder.CreateBitOrPointerCast(V, CV->
getType());
1210 if (
Instruction *BitcastInst = dyn_cast<Instruction>(Bitcast))
1211 reorder(BitcastInst);
1214 eraseInstructions(Chain);
1216 ++NumVectorInstructions;
1217 NumScalarsVectorized += Chain.size();
1221 bool Vectorizer::accessIsMisaligned(
unsigned SzInBytes,
unsigned AddressSpace,
1222 unsigned Alignment) {
1223 if (Alignment % SzInBytes == 0)
1230 LLVM_DEBUG(
dbgs() <<
"LSV: Target said misaligned is allowed? " << Allows
1231 <<
" and fast? " << Fast <<
"\n";);
1232 return !Allows || !
Fast;
Legacy wrapper pass to provide the GlobalsAAResult object.
Pass interface - Implemented by all 'passes'.
const T & front() const
front - Get the first element.
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. ...
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
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.
Compute iterated dominance frontiers using a linear time algorithm.
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
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.
APInt zext(unsigned width) const
Zero extend to a new width.
APInt udiv(const APInt &RHS) const
Unsigned division operation.
bool dominates(const Instruction *A, const Instruction *B)
Find out whether A dominates B, meaning whether A comes before B in BB.
bool mayWriteToMemory() const
Return true if this instruction may modify memory.
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
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...
APInt trunc(unsigned width) const
Truncate to new width.
STATISTIC(NumFunctions, "Total number of functions")
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
An instruction for reading from memory.
bool isVectorTy() const
True if this is an instance of VectorType.
bool sle(const APInt &RHS) const
Signed less or equal comparison.
unsigned getBitWidth() const
Return the number of bits in the APInt.
void dump() const
Support for debugging, callable in GDB: V->dump()
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
static uint32_t getAlignment(const MCSectionCOFF &Sec)
Type * getPointerElementType() const
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
LLVMContext & getContext() const
Get the global data context.
APInt zextOrSelf(unsigned width) const
Zero extend or truncate to width.
A Use represents the edge between a Value definition and its users.
LLVMContext & getContext() const
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
This file contains the simple types necessary to represent the attributes associated with functions a...
uint64_t getNumElements() const
This file implements a class to represent arbitrary precision integral constant values and operations...
unsigned getPointerAddressSpace() const
Returns the address space of the pointer operand.
Type * getType() const
All values are typed, get the type of this value.
void initializeLoadStoreVectorizerPass(PassRegistry &)
void clearBit(unsigned BitPosition)
Set a given bit to 0.
static bool isValidElementType(Type *ElemTy)
Return true if the specified type is valid as a element type.
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)...
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
Value * getLoadStorePointerOperand(Value *V)
A helper function that returns the pointer operand of a load or store instruction.
Pass * createLoadStoreVectorizerPass()
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...
Value * getOperand(unsigned i) const
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
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 ...
bool isNegative() const
Determine sign of this APInt.
static bool runOnFunction(Function &F, bool PostInlining)
static MemoryLocation get(const LoadInst *LI)
Return a location with information about the memory reference by the given instruction.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
APInt urem(const APInt &RHS) const
Unsigned remainder operation.
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...
static const unsigned StackAdjustedAlignment
bool ult(const APInt &RHS) const
Unsigned less than comparison.
size_t size() const
size - Get the array size.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
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.
bool mayThrow() const
Return true if this instruction may throw an exception.
bool isMinSignedValue() const
Determine if this is the smallest signed value.
Represent the analysis usage information of a pass.
FunctionPass class - This class is used to implement most global optimizations.
Value * getPointerOperand()
iterator_range< po_iterator< T > > post_order(const T &G)
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
self_iterator getIterator()
void setAlignment(unsigned Align)
Type * getIndexedType() const
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...
Fast - This calling convention attempts to make calls as fast as possible (e.g.
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE, "Assign register bank of generic virtual registers", false, false) RegBankSelect
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
bool isPtrOrPtrVectorTy() const
Return true if this is a pointer type or a vector of pointer types.
Iterator for intrusive lists based on ilist_node.
unsigned getNumOperands() const
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
static unsigned getIntrinsicID(const SDNode *N)
Legacy wrapper pass to provide the SCEVAAResult object.
unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type...
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.
unsigned getABITypeAlignment(Type *Ty) const
Returns the minimum ABI-required alignment for the specified type.
LLVM_NODISCARD T pop_back_val()
static IntegerType * getIntNTy(LLVMContext &C, unsigned N)
void negate()
Negate this APInt in place.
void setPreservesCFG()
This function should be called by the pass, iff they do not:
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Class to represent vector types.
const Value * stripAndAccumulateInBoundsConstantOffsets(const DataLayout &DL, APInt &Offset) const
Accumulate offsets from stripInBoundsConstantOffsets().
Class for arbitrary precision integers.
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...
void removeFromParent()
This method unlinks 'this' from the containing basic block, but does not delete it.
unsigned getAlignment() const
Return the alignment of the access that is being performed.
This class represents an analyzed expression in the program.
static ChainID getChainID(const Value *Ptr, const DataLayout &DL)
Value * getOperand() const
LLVM_NODISCARD bool empty() const
This file provides utility analysis objects describing memory locations.
StringRef getName() const
Return a constant reference to the value's name.
APFloat abs(APFloat X)
Returns the absolute value of the argument.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
unsigned getAlignment() const
Return the alignment of the access that is being performed.
INITIALIZE_PASS_BEGIN(LoadStoreVectorizer, DEBUG_TYPE, "Vectorize load and Store instructions", false, false) INITIALIZE_PASS_END(LoadStoreVectorizer
unsigned getPointerAddressSpace() const
Returns the address space of the pointer operand.
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)
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
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)
StringRef - Represent a constant reference to a string, i.e.
inst_range instructions(Function *F)
Legacy analysis pass which computes a DominatorTree.
A wrapper pass to provide the legacy pass manager access to a suitably prepared AAResults object...
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...
bool empty() const
empty - Check if the array is empty.
const BasicBlock * getParent() const
gep_type_iterator gep_type_begin(const User *GEP)
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.
bool mayReadOrWriteMemory() const
Return true if this instruction may read or write memory.