File indexing completed on 2026-05-10 08:44:45
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #ifndef LLVM_TRANSFORMS_VECTORIZE_SLPVECTORIZER_H
0019 #define LLVM_TRANSFORMS_VECTORIZE_SLPVECTORIZER_H
0020
0021 #include "llvm/ADT/ArrayRef.h"
0022 #include "llvm/ADT/MapVector.h"
0023 #include "llvm/ADT/SetVector.h"
0024 #include "llvm/ADT/SmallVector.h"
0025 #include "llvm/IR/PassManager.h"
0026
0027 namespace llvm {
0028
0029 class AAResults;
0030 class AssumptionCache;
0031 class BasicBlock;
0032 class DataLayout;
0033 class DemandedBits;
0034 class DominatorTree;
0035 class Function;
0036 class GetElementPtrInst;
0037 class InsertElementInst;
0038 class InsertValueInst;
0039 class Instruction;
0040 class LoopInfo;
0041 class OptimizationRemarkEmitter;
0042 class PHINode;
0043 class ScalarEvolution;
0044 class StoreInst;
0045 class TargetLibraryInfo;
0046 class TargetTransformInfo;
0047 class Value;
0048 class WeakTrackingVH;
0049
0050
0051
0052 namespace slpvectorizer {
0053
0054 class BoUpSLP;
0055
0056 }
0057
0058 struct SLPVectorizerPass : public PassInfoMixin<SLPVectorizerPass> {
0059 using StoreList = SmallVector<StoreInst *, 8>;
0060 using StoreListMap = MapVector<Value *, StoreList>;
0061 using GEPList = SmallVector<GetElementPtrInst *, 8>;
0062 using GEPListMap = MapVector<Value *, GEPList>;
0063 using InstSetVector = SmallSetVector<Instruction *, 8>;
0064
0065 ScalarEvolution *SE = nullptr;
0066 TargetTransformInfo *TTI = nullptr;
0067 TargetLibraryInfo *TLI = nullptr;
0068 AAResults *AA = nullptr;
0069 LoopInfo *LI = nullptr;
0070 DominatorTree *DT = nullptr;
0071 AssumptionCache *AC = nullptr;
0072 DemandedBits *DB = nullptr;
0073 const DataLayout *DL = nullptr;
0074
0075 public:
0076 PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
0077
0078
0079 bool runImpl(Function &F, ScalarEvolution *SE_, TargetTransformInfo *TTI_,
0080 TargetLibraryInfo *TLI_, AAResults *AA_, LoopInfo *LI_,
0081 DominatorTree *DT_, AssumptionCache *AC_, DemandedBits *DB_,
0082 OptimizationRemarkEmitter *ORE_);
0083
0084 private:
0085
0086
0087
0088
0089
0090
0091
0092 void collectSeedInstructions(BasicBlock *BB);
0093
0094
0095
0096
0097 bool tryToVectorizeList(ArrayRef<Value *> VL, slpvectorizer::BoUpSLP &R,
0098 bool MaxVFOnly = false);
0099
0100
0101 bool tryToVectorize(Instruction *I, slpvectorizer::BoUpSLP &R);
0102
0103
0104
0105 bool tryToVectorize(ArrayRef<WeakTrackingVH> Insts,
0106 slpvectorizer::BoUpSLP &R);
0107
0108
0109 bool vectorizeStoreChains(slpvectorizer::BoUpSLP &R);
0110
0111
0112
0113 bool vectorizeGEPIndices(BasicBlock *BB, slpvectorizer::BoUpSLP &R);
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123 bool vectorizeHorReduction(PHINode *P, Instruction *Root, BasicBlock *BB,
0124 slpvectorizer::BoUpSLP &R,
0125 SmallVectorImpl<WeakTrackingVH> &PostponedInsts);
0126
0127
0128
0129
0130 bool vectorizeRootInstruction(PHINode *P, Instruction *Root, BasicBlock *BB,
0131 slpvectorizer::BoUpSLP &R);
0132
0133
0134 bool vectorizeInsertValueInst(InsertValueInst *IVI, BasicBlock *BB,
0135 slpvectorizer::BoUpSLP &R, bool MaxVFOnly);
0136
0137
0138 bool vectorizeInsertElementInst(InsertElementInst *IEI, BasicBlock *BB,
0139 slpvectorizer::BoUpSLP &R, bool MaxVFOnly);
0140
0141
0142 template <typename ItT>
0143 bool vectorizeCmpInsts(iterator_range<ItT> CmpInsts, BasicBlock *BB,
0144 slpvectorizer::BoUpSLP &R);
0145
0146
0147
0148 bool vectorizeInserts(InstSetVector &Instructions, BasicBlock *BB,
0149 slpvectorizer::BoUpSLP &R);
0150
0151
0152
0153 bool vectorizeChainsInBlock(BasicBlock *BB, slpvectorizer::BoUpSLP &R);
0154
0155 std::optional<bool> vectorizeStoreChain(ArrayRef<Value *> Chain,
0156 slpvectorizer::BoUpSLP &R,
0157 unsigned Idx, unsigned MinVF,
0158 unsigned &Size);
0159
0160 bool vectorizeStores(
0161 ArrayRef<StoreInst *> Stores, slpvectorizer::BoUpSLP &R,
0162 DenseSet<std::tuple<Value *, Value *, Value *, Value *, unsigned>>
0163 &Visited);
0164
0165
0166 StoreListMap Stores;
0167
0168
0169 GEPListMap GEPs;
0170 };
0171
0172 }
0173
0174 #endif