91 #define DEBUG_TYPE "load-store-vectorizer" 93 STATISTIC(NumVectorInstructions,
"Number of vector accesses generated");
94 STATISTIC(NumScalarsVectorized,
"Number of scalar accesses vectorized");
108 using ChainID =
const Value *;
124 :
F(F), AA(AA), DT(DT), SE(SE), TTI(TTI),
130 unsigned getPointerAddressSpace(
Value *
I);
152 unsigned Depth = 0)
const;
153 bool lookThroughComplexAddresses(
Value *PtrA,
Value *PtrB,
APInt PtrDelta,
154 unsigned Depth)
const;
155 bool lookThroughSelects(
Value *PtrA,
Value *PtrB,
const APInt &PtrDelta,
156 unsigned Depth)
const;
163 std::pair<BasicBlock::iterator, BasicBlock::iterator>
185 std::pair<InstrListMap, InstrListMap> collectInstructions(
BasicBlock *BB);
189 bool vectorizeChains(InstrListMap &Map);
205 bool accessIsMisaligned(
unsigned SzInBytes,
unsigned AddressSpace,
209 class LoadStoreVectorizerLegacyPass :
public FunctionPass {
220 return "GPU Load and Store Vectorizer";
237 "Vectorize load and Store instructions",
false,
false)
247 return new LoadStoreVectorizerLegacyPass();
252 if (skipFunction(F) || F.
hasFnAttribute(Attribute::NoImplicitFloat))
255 AliasAnalysis &AA = getAnalysis<AAResultsWrapperPass>().getAAResults();
256 DominatorTree &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree();
257 ScalarEvolution &SE = getAnalysis<ScalarEvolutionWrapperPass>().getSE();
259 getAnalysis<TargetTransformInfoWrapperPass>().getTTI(F);
261 Vectorizer V(F, AA, DT, SE, TTI);
275 Vectorizer V(F, AA, DT, SE, TTI);
276 bool Changed = V.run();
290 bool Vectorizer::run() {
291 bool Changed =
false;
295 InstrListMap LoadRefs, StoreRefs;
296 std::tie(LoadRefs, StoreRefs) = collectInstructions(BB);
297 Changed |= vectorizeChains(LoadRefs);
298 Changed |= vectorizeChains(StoreRefs);
304 unsigned Vectorizer::getPointerAddressSpace(
Value *
I) {
305 if (
LoadInst *L = dyn_cast<LoadInst>(I))
306 return L->getPointerAddressSpace();
307 if (
StoreInst *S = dyn_cast<StoreInst>(I))
308 return S->getPointerAddressSpace();
316 unsigned ASA = getPointerAddressSpace(A);
317 unsigned ASB = getPointerAddressSpace(B);
320 if (!PtrA || !PtrB || (ASA != ASB))
328 DL.getTypeStoreSize(PtrATy) != DL.getTypeStoreSize(PtrBTy) ||
333 unsigned PtrBitWidth = DL.getPointerSizeInBits(ASA);
334 APInt Size(PtrBitWidth, DL.getTypeStoreSize(PtrATy));
336 return areConsecutivePointers(PtrA, PtrB,
Size);
339 bool Vectorizer::areConsecutivePointers(
Value *PtrA,
Value *PtrB,
341 unsigned PtrBitWidth = DL.getPointerTypeSizeInBits(PtrA->
getType());
342 APInt OffsetA(PtrBitWidth, 0);
343 APInt OffsetB(PtrBitWidth, 0);
347 unsigned NewPtrBitWidth = DL.getTypeStoreSizeInBits(PtrA->
getType());
349 if (NewPtrBitWidth != DL.getTypeStoreSizeInBits(PtrB->
getType()))
363 APInt OffsetDelta = OffsetB - OffsetA;
368 return OffsetDelta == PtrDelta;
372 APInt BaseDelta = PtrDelta - OffsetDelta;
375 const SCEV *PtrSCEVA = SE.getSCEV(PtrA);
376 const SCEV *PtrSCEVB = SE.getSCEV(PtrB);
377 const SCEV *
C = SE.getConstant(BaseDelta);
378 const SCEV *
X = SE.getAddExpr(PtrSCEVA, C);
386 const SCEV *Dist = SE.getMinusSCEV(PtrSCEVB, PtrSCEVA);
393 return lookThroughComplexAddresses(PtrA, PtrB, BaseDelta, Depth);
396 bool Vectorizer::lookThroughComplexAddresses(
Value *PtrA,
Value *PtrB,
398 unsigned Depth)
const {
402 return lookThroughSelects(PtrA, PtrB, PtrDelta, Depth);
406 if (GEPA->getNumOperands() != GEPB->getNumOperands() ||
407 GEPA->getPointerOperand() != GEPB->getPointerOperand())
411 for (
unsigned I = 0,
E = GEPA->getNumIndices() - 1; I <
E; ++
I) {
420 if (!OpA || !OpB || OpA->
getOpcode() != OpB->getOpcode() ||
421 OpA->
getType() != OpB->getType())
431 if (PtrDelta.
urem(Stride) != 0)
437 if (!isa<SExtInst>(OpA) && !isa<ZExtInst>(OpA))
440 bool Signed = isa<SExtInst>(OpA);
445 if (!OpB || ValA->getType() != OpB->getType())
453 isa<ConstantInt>(OpB->getOperand(1)) &&
454 IdxDiff.
sle(cast<ConstantInt>(OpB->getOperand(1))->getSExtValue())) {
461 unsigned BitWidth = ValA->getType()->getScalarSizeInBits();
475 BitsAllowedToBeSet.
clearBit(BitWidth - 1);
476 if (BitsAllowedToBeSet.
ult(IdxDiff))
480 const SCEV *OffsetSCEVA = SE.getSCEV(ValA);
481 const SCEV *OffsetSCEVB = SE.getSCEV(OpB);
482 const SCEV *
C = SE.getConstant(IdxDiff.
trunc(BitWidth));
483 const SCEV *
X = SE.getAddExpr(OffsetSCEVA, C);
484 return X == OffsetSCEVB;
487 bool Vectorizer::lookThroughSelects(
Value *PtrA,
Value *PtrB,
488 const APInt &PtrDelta,
489 unsigned Depth)
const {
493 if (
auto *SelectA = dyn_cast<SelectInst>(PtrA)) {
494 if (
auto *SelectB = dyn_cast<SelectInst>(PtrB)) {
495 return SelectA->getCondition() == SelectB->getCondition() &&
496 areConsecutivePointers(SelectA->getTrueValue(),
497 SelectB->getTrueValue(), PtrDelta,
Depth) &&
498 areConsecutivePointers(SelectA->getFalseValue(),
499 SelectB->getFalseValue(), PtrDelta,
Depth);
511 while (!Worklist.
empty()) {
514 for (
int i = 0; i < NumOperands; i++) {
516 if (!IM || IM->
getOpcode() == Instruction::PHI)
524 if (!OBB.dominates(IM, I)) {
525 InstructionsToMove.insert(IM);
534 if (!InstructionsToMove.count(&*BBI))
543 std::pair<BasicBlock::iterator, BasicBlock::iterator>
550 unsigned NumFound = 0;
559 if (NumFound == Chain.
size()) {
566 return std::make_pair(FirstInstr, ++LastInstr);
573 assert(PtrOperand &&
"Instruction must have a pointer operand.");
587 unsigned ElementSizeBits) {
588 unsigned ElementSizeBytes = ElementSizeBits / 8;
589 unsigned SizeBytes = ElementSizeBytes * Chain.
size();
590 unsigned NumLeft = (SizeBytes - (SizeBytes % 4)) / ElementSizeBytes;
591 if (NumLeft == Chain.
size()) {
592 if ((NumLeft & 1) == 0)
596 }
else if (NumLeft == 0)
598 return std::make_pair(Chain.
slice(0, NumLeft), Chain.
slice(NumLeft));
607 bool IsLoadChain = isa<LoadInst>(Chain[0]);
611 assert(isa<LoadInst>(I) &&
612 "All elements of Chain must be loads, or all must be stores.");
614 assert(isa<StoreInst>(I) &&
615 "All elements of Chain must be loads, or all must be stores.");
620 if (isa<LoadInst>(I) || isa<StoreInst>(
I)) {
625 }
else if (isa<IntrinsicInst>(&I) &&
627 Intrinsic::sideeffect) {
630 LLVM_DEBUG(
dbgs() <<
"LSV: Found may-write/throw operation: " << I
634 LLVM_DEBUG(
dbgs() <<
"LSV: Found may-read/write/throw operation: " << I
643 unsigned ChainInstrIdx = 0;
646 for (
unsigned E = ChainInstrs.
size(); ChainInstrIdx <
E; ++ChainInstrIdx) {
647 Instruction *ChainInstr = ChainInstrs[ChainInstrIdx];
651 if (BarrierMemoryInstr && OBB.
dominates(BarrierMemoryInstr, ChainInstr))
658 if (BarrierMemoryInstr && OBB.
dominates(BarrierMemoryInstr, MemInstr))
663 if (MemLoad && ChainLoad)
668 auto IsInvariantLoad = [](
const LoadInst *LI) ->
bool {
669 return LI->
hasMetadata(LLVMContext::MD_invariant_load);
676 if (isa<StoreInst>(MemInstr) && ChainLoad &&
677 (IsInvariantLoad(ChainLoad) || OBB.
dominates(ChainLoad, MemInstr)))
681 if (MemLoad && isa<StoreInst>(ChainInstr) &&
682 (IsInvariantLoad(MemLoad) || OBB.
dominates(MemLoad, ChainInstr)))
688 dbgs() <<
"LSV: Found alias:\n" 689 " Aliasing instruction and pointer:\n" 690 <<
" " << *MemInstr <<
'\n' 692 <<
" Aliased instruction and pointer:\n" 693 <<
" " << *ChainInstr <<
'\n' 698 BarrierMemoryInstr = MemInstr;
706 if (IsLoadChain && BarrierMemoryInstr) {
718 ChainInstrs.
begin(), ChainInstrs.
begin() + ChainInstrIdx);
719 unsigned ChainIdx = 0;
720 for (
unsigned ChainLen = Chain.
size(); ChainIdx < ChainLen; ++ChainIdx) {
721 if (!VectorizableChainInstrs.count(Chain[ChainIdx]))
724 return Chain.
slice(0, ChainIdx);
729 if (
const auto *Sel = dyn_cast<SelectInst>(ObjPtr)) {
736 return Sel->getCondition();
741 std::pair<InstrListMap, InstrListMap>
742 Vectorizer::collectInstructions(
BasicBlock *BB) {
743 InstrListMap LoadRefs;
744 InstrListMap StoreRefs;
750 if (
LoadInst *LI = dyn_cast<LoadInst>(&I)) {
755 if (!TTI.isLegalToVectorizeLoad(LI))
758 Type *Ty = LI->getType();
764 unsigned TySize = DL.getTypeSizeInBits(Ty);
765 if ((TySize % 8) != 0)
775 Value *Ptr = LI->getPointerOperand();
777 unsigned VecRegSize = TTI.getLoadStoreVecRegBitWidth(AS);
779 unsigned VF = VecRegSize / TySize;
783 if (TySize > VecRegSize / 2 ||
784 (VecTy && TTI.getLoadVectorFactor(VF, TySize, TySize / 8, VecTy) == 0))
790 return EEI && isa<ConstantInt>(EEI->
getOperand(1));
796 LoadRefs[
ID].push_back(LI);
797 }
else if (
StoreInst *
SI = dyn_cast<StoreInst>(&I)) {
802 if (!TTI.isLegalToVectorizeStore(
SI))
805 Type *Ty =
SI->getValueOperand()->getType();
818 unsigned TySize = DL.getTypeSizeInBits(Ty);
819 if ((TySize % 8) != 0)
822 Value *Ptr =
SI->getPointerOperand();
824 unsigned VecRegSize = TTI.getLoadStoreVecRegBitWidth(AS);
826 unsigned VF = VecRegSize / TySize;
830 if (TySize > VecRegSize / 2 ||
831 (VecTy && TTI.getStoreVectorFactor(VF, TySize, TySize / 8, VecTy) == 0))
836 return EEI && isa<ConstantInt>(EEI->
getOperand(1));
842 StoreRefs[
ID].push_back(
SI);
846 return {LoadRefs, StoreRefs};
849 bool Vectorizer::vectorizeChains(InstrListMap &Map) {
850 bool Changed =
false;
852 for (
const std::pair<ChainID, InstrList> &Chain : Map) {
853 unsigned Size = Chain.second.
size();
857 LLVM_DEBUG(
dbgs() <<
"LSV: Analyzing a chain of length " << Size <<
".\n");
860 for (
unsigned CI = 0, CE = Size; CI < CE; CI += 64) {
861 unsigned Len = std::min<unsigned>(CE - CI, 64);
863 Changed |= vectorizeInstructions(Chunk);
872 <<
" instructions.\n");
874 int ConsecutiveChain[64];
878 for (
int i = 0,
e = Instrs.
size(); i <
e; ++i) {
879 ConsecutiveChain[i] = -1;
880 for (
int j = e - 1; j >= 0; --j) {
885 if (ConsecutiveChain[i] != -1) {
886 int CurDistance =
std::abs(ConsecutiveChain[i] - i);
887 int NewDistance =
std::abs(ConsecutiveChain[i] - j);
888 if (j < i || NewDistance > CurDistance)
894 ConsecutiveChain[i] = j;
899 bool Changed =
false;
902 for (
int Head : Heads) {
903 if (InstructionsProcessed.
count(Instrs[Head]))
905 bool LongerChainExists =
false;
906 for (
unsigned TIt = 0; TIt < Tails.size(); TIt++)
907 if (Head == Tails[TIt] &&
908 !InstructionsProcessed.
count(Instrs[Heads[TIt]])) {
909 LongerChainExists =
true;
912 if (LongerChainExists)
920 if (InstructionsProcessed.
count(Instrs[I]))
924 I = ConsecutiveChain[
I];
927 bool Vectorized =
false;
928 if (isa<LoadInst>(*Operands.
begin()))
929 Vectorized = vectorizeLoadChain(Operands, &InstructionsProcessed);
931 Vectorized = vectorizeStoreChain(Operands, &InstructionsProcessed);
933 Changed |= Vectorized;
939 bool Vectorizer::vectorizeStoreChain(
942 StoreInst *S0 = cast<StoreInst>(Chain[0]);
945 Type *StoreTy =
nullptr;
947 StoreTy = cast<StoreInst>(
I)->getValueOperand()->getType();
948 if (StoreTy->isIntOrIntVectorTy())
951 if (StoreTy->isPtrOrPtrVectorTy()) {
953 DL.getTypeSizeInBits(StoreTy));
957 assert(StoreTy &&
"Failed to find store type");
959 unsigned Sz = DL.getTypeSizeInBits(StoreTy);
961 unsigned VecRegSize = TTI.getLoadStoreVecRegBitWidth(AS);
962 unsigned VF = VecRegSize / Sz;
963 unsigned ChainSize = Chain.size();
967 InstructionsProcessed->
insert(Chain.begin(), Chain.end());
972 if (NewChain.
empty()) {
974 InstructionsProcessed->
insert(Chain.begin(), Chain.end());
977 if (NewChain.
size() == 1) {
985 ChainSize = Chain.size();
989 unsigned EltSzInBytes = Sz / 8;
990 unsigned SzInBytes = EltSzInBytes * ChainSize;
1002 unsigned TargetVF = TTI.getStoreVectorFactor(VF, Sz, SzInBytes, VecTy);
1003 if (ChainSize > VF || (VF != TargetVF && TargetVF < ChainSize)) {
1004 LLVM_DEBUG(
dbgs() <<
"LSV: Chain doesn't match with the vector factor." 1005 " Creating two separate arrays.\n");
1006 return vectorizeStoreChain(Chain.slice(0, TargetVF),
1007 InstructionsProcessed) |
1008 vectorizeStoreChain(Chain.slice(TargetVF), InstructionsProcessed);
1012 dbgs() <<
"LSV: Stores to vectorize:\n";
1014 dbgs() <<
" " << *I <<
"\n";
1019 InstructionsProcessed->
insert(Chain.begin(), Chain.end());
1022 if (accessIsMisaligned(SzInBytes, AS, Alignment)) {
1024 auto Chains = splitOddVectorElts(Chain, Sz);
1025 return vectorizeStoreChain(Chains.first, InstructionsProcessed) |
1026 vectorizeStoreChain(Chains.second, InstructionsProcessed);
1031 DL, S0,
nullptr, &DT);
1033 Alignment = NewAlign;
1036 if (!TTI.isLegalToVectorizeStoreChain(SzInBytes, Alignment, AS)) {
1037 auto Chains = splitOddVectorElts(Chain, Sz);
1038 return vectorizeStoreChain(Chains.first, InstructionsProcessed) |
1039 vectorizeStoreChain(Chains.second, InstructionsProcessed);
1043 std::tie(First, Last) = getBoundaryInstrs(Chain);
1044 Builder.SetInsertPoint(&*Last);
1050 for (
unsigned I = 0,
E = Chain.size(); I !=
E; ++
I) {
1053 unsigned NewIdx = J + I * VecWidth;
1055 Builder.getInt32(J));
1057 Extract = Builder.CreateBitCast(Extract, StoreTy->getScalarType());
1060 Builder.CreateInsertElement(Vec, Extract, Builder.getInt32(NewIdx));
1065 for (
unsigned I = 0,
E = Chain.size(); I !=
E; ++
I) {
1068 if (Extract->getType() != StoreTy->getScalarType())
1070 Builder.CreateBitOrPointerCast(Extract, StoreTy->getScalarType());
1073 Builder.CreateInsertElement(Vec, Extract, Builder.getInt32(I));
1084 eraseInstructions(Chain);
1085 ++NumVectorInstructions;
1086 NumScalarsVectorized += Chain.size();
1090 bool Vectorizer::vectorizeLoadChain(
1093 LoadInst *L0 = cast<LoadInst>(Chain[0]);
1096 Type *LoadTy =
nullptr;
1097 for (
const auto &V : Chain) {
1098 LoadTy = cast<LoadInst>(V)->
getType();
1099 if (LoadTy->isIntOrIntVectorTy())
1102 if (LoadTy->isPtrOrPtrVectorTy()) {
1104 DL.getTypeSizeInBits(LoadTy));
1108 assert(LoadTy &&
"Can't determine LoadInst type from chain");
1110 unsigned Sz = DL.getTypeSizeInBits(LoadTy);
1112 unsigned VecRegSize = TTI.getLoadStoreVecRegBitWidth(AS);
1113 unsigned VF = VecRegSize / Sz;
1114 unsigned ChainSize = Chain.size();
1118 InstructionsProcessed->
insert(Chain.begin(), Chain.end());
1123 if (NewChain.
empty()) {
1125 InstructionsProcessed->
insert(Chain.begin(), Chain.end());
1128 if (NewChain.
size() == 1) {
1136 ChainSize = Chain.size();
1140 unsigned EltSzInBytes = Sz / 8;
1141 unsigned SzInBytes = EltSzInBytes * ChainSize;
1152 unsigned TargetVF = TTI.getLoadVectorFactor(VF, Sz, SzInBytes, VecTy);
1153 if (ChainSize > VF || (VF != TargetVF && TargetVF < ChainSize)) {
1154 LLVM_DEBUG(
dbgs() <<
"LSV: Chain doesn't match with the vector factor." 1155 " Creating two separate arrays.\n");
1156 return vectorizeLoadChain(Chain.slice(0, TargetVF), InstructionsProcessed) |
1157 vectorizeLoadChain(Chain.slice(TargetVF), InstructionsProcessed);
1162 InstructionsProcessed->
insert(Chain.begin(), Chain.end());
1165 if (accessIsMisaligned(SzInBytes, AS, Alignment)) {
1167 auto Chains = splitOddVectorElts(Chain, Sz);
1168 return vectorizeLoadChain(Chains.first, InstructionsProcessed) |
1169 vectorizeLoadChain(Chains.second, InstructionsProcessed);
1176 if (!TTI.isLegalToVectorizeLoadChain(SzInBytes, Alignment, AS)) {
1177 auto Chains = splitOddVectorElts(Chain, Sz);
1178 return vectorizeLoadChain(Chains.first, InstructionsProcessed) |
1179 vectorizeLoadChain(Chains.second, InstructionsProcessed);
1183 dbgs() <<
"LSV: Loads to vectorize:\n";
1192 std::tie(First, Last) = getBoundaryInstrs(Chain);
1193 Builder.SetInsertPoint(&*First);
1197 LoadInst *LI = Builder.CreateAlignedLoad(VecTy, Bitcast, Alignment);
1204 for (
unsigned I = 0,
E = Chain.size(); I !=
E; ++
I) {
1205 for (
auto Use : Chain[I]->
users()) {
1209 unsigned Idx = cast<ConstantInt>(UI->
getOperand(1))->getZExtValue();
1210 unsigned NewIdx = Idx + I * VecWidth;
1211 Value *V = Builder.CreateExtractElement(LI, Builder.getInt32(NewIdx),
1214 V = Builder.CreateBitCast(V, UI->
getType());
1224 if (
Instruction *BitcastInst = dyn_cast<Instruction>(Bitcast))
1225 reorder(BitcastInst);
1227 for (
auto I : InstrsToErase)
1230 for (
unsigned I = 0,
E = Chain.size(); I !=
E; ++
I) {
1233 Builder.CreateExtractElement(LI, Builder.getInt32(I), CV->
getName());
1235 V = Builder.CreateBitOrPointerCast(V, CV->
getType());
1242 if (
Instruction *BitcastInst = dyn_cast<Instruction>(Bitcast))
1243 reorder(BitcastInst);
1246 eraseInstructions(Chain);
1248 ++NumVectorInstructions;
1249 NumScalarsVectorized += Chain.size();
1253 bool Vectorizer::accessIsMisaligned(
unsigned SzInBytes,
unsigned AddressSpace,
1254 unsigned Alignment) {
1255 if (Alignment % SzInBytes == 0)
1262 LLVM_DEBUG(
dbgs() <<
"LSV: Target said misaligned is allowed? " << Allows
1263 <<
" and fast? " << Fast <<
"\n";);
1264 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.
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, bool UseInstrInfo=true)
Determine which bits of V are known to be either zero or one and return them in the KnownZero/KnownOn...
Value * getValueOperand()
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
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.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
This class represents lattice values for constants.
void push_back(const T &Elt)
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, MD_access_group].
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.
Analysis pass providing the TargetTransformInfo.
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")
Analysis pass which computes a DominatorTree.
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()
const Value * getLoadStorePointerOperand(const Value *V)
A helper function that returns the pointer operand of a load or store instruction.
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
static uint32_t getAlignment(const MCSectionCOFF &Sec)
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
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 file contains the simple types necessary to represent the attributes associated with functions a...
bool hasMetadata() const
Return true if this instruction has any metadata attached to it.
mir Rename Register Operands
uint64_t getNumElements() const
For scalable vectors, this will return the minimum number of elements in the vector.
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 clearBit(unsigned BitPosition)
Set a given bit to 0.
APInt sextOrTrunc(unsigned width) const
Sign extend or truncate to width.
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)...
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
Pass * createLoadStoreVectorizerPass()
Create a legacy pass manager instance of the LoadStoreVectorizer pass.
const Value * stripAndAccumulateInBoundsConstantOffsets(const DataLayout &DL, APInt &Offset) const
This is a wrapper around stripAndAccumulateConstantOffsets with the in-bounds requirement set to fals...
An instruction for storing to memory.
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
static bool hasNoSignedWrap(BinaryOperator &I)
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")
A set of analyses that are preserved following a run of a transformation pass.
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")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
A manager for alias analyses.
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()
static bool hasNoUnsignedWrap(BinaryOperator &I)
Type * getIndexedType() const
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
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...
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE, "Assign register bank of generic virtual registers", false, false) RegBankSelect
This struct is a compact representation of a valid (non-zero power of two) alignment.
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.
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...
Represents analyses that only rely on functions' control flow.
void removeFromParent()
This method unlinks 'this' from the containing basic block, but does not delete it.
Analysis pass that exposes the ScalarEvolution for a function.
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.
static VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
void preserveSet()
Mark an analysis set as preserved.
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 FIXME: Remove this function once transitio...
unsigned getPointerAddressSpace() const
Returns the address space of the pointer operand.
INITIALIZE_PASS_BEGIN(LoadStoreVectorizerLegacyPass, DEBUG_TYPE, "Vectorize load and Store instructions", false, false) INITIALIZE_PASS_END(LoadStoreVectorizerLegacyPass
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
unsigned getMinSignedBits() const
Get the minimum bit size for this signed APInt.
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
Fast - This calling convention attempts to make calls as fast as possible (e.g.
static const Function * getParent(const Value *V)
void initializeLoadStoreVectorizerLegacyPassPass(PassRegistry &)
StringRef - Represent a constant reference to a string, i.e.
inst_range instructions(Function *F)
A container for analyses that lazily runs them and caches their results.
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()
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.