23 cl::desc(
"Limit the size of the seed bundle to cap compilation time."));
27 cl::desc(
"Limit the number of collected seeds groups in a BB to "
28 "cap compilation time."));
31 unsigned MaxVecRegBits,
44 assert(!
isUsed(StartIdx) &&
"Expected unused at StartIdx");
48 if (
isUsed(StartIdx + NumElements))
52 if (BitCount + InstBits > MaxVecRegBits)
57 NumElementsPowerOfTwo = NumElements;
58 BitCountPowerOfTwo = BitCount;
62 NumElements = NumElementsPowerOfTwo;
63 BitCount = BitCountPowerOfTwo;
67 if (NumElements > 1) {
69 "Must be a power of two");
75template <
typename LoadOrStoreT>
76SeedContainer::KeyT SeedContainer::getKey(LoadOrStoreT *LSI,
77 bool AllowDiffTypes)
const {
78 assert((isa<LoadInst>(LSI) || isa<StoreInst>(LSI)) &&
79 "Expected Load or Store!");
87 if (
auto *VTy = dyn_cast<VectorType>(Ty))
88 Ty = VTy->getElementType();
94template SeedContainer::KeyT
95SeedContainer::getKey<LoadInst>(
LoadInst *LSI,
bool AllowDiffTypes)
const;
96template SeedContainer::KeyT
97SeedContainer::getKey<StoreInst>(
StoreInst *LSI,
bool AllowDiffTypes)
const;
100 assert((isa<LoadInst>(
I) || isa<StoreInst>(
I)) &&
"Expected Load or Store!");
101 auto It = SeedLookupMap.find(
I);
102 if (It == SeedLookupMap.end())
109template <
typename LoadOrStoreT>
112 auto &BundleVec = Bundles[getKey(LSI, AllowDiffTypes)];
119 BundleVec.
back()->insert(LSI, SE);
121 SeedLookupMap[LSI] = BundleVec.back().get();
132 for (
const auto &Pair : Bundles) {
133 auto [
I, Ty,
Opc] = Pair.first;
134 const auto &SeedsVec = Pair.second;
135 std::string RefType = dyn_cast<LoadInst>(
I) ?
"Load"
136 : dyn_cast<StoreInst>(
I) ?
"Store"
138 OS <<
"[Inst=" << *
I <<
" Ty=" << Ty <<
" " << RefType <<
"]\n";
139 for (
const auto &SeedPtr : SeedsVec) {
151 if (!LSI->isSimple())
158 if (isa<ScalableVectorType>(Ty))
160 if (
auto *VTy = dyn_cast<FixedVectorType>(Ty))
169 bool CollectStores,
bool CollectLoads,
171 : StoreSeeds(SE), LoadSeeds(SE), Ctx(BB->getContext()) {
173 if (!CollectStores && !CollectLoads)
177 if (
auto SI = dyn_cast<StoreInst>(
I))
178 StoreSeeds.
erase(SI);
179 else if (
auto LI = dyn_cast<LoadInst>(
I))
184 for (
auto &
I : *BB) {
187 StoreSeeds.
insert(SI, AllowDiffTypes);
188 if (
LoadInst *LI = dyn_cast<LoadInst>(&
I))
190 LoadSeeds.
insert(LI, AllowDiffTypes);
203 OS <<
"=== StoreSeeds ===\n";
205 OS <<
"=== LoadSeeds ===\n";
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
#define LLVM_EXPORT_TEMPLATE
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
This class represents an Operation in the Expression.
An instruction for reading from memory.
std::pair< KeyT, ValueT > & back()
The main scalar evolution driver.
An instruction for storing to memory.
This class implements an extremely fast bulk output stream that can only output to a stream.
Contains a list of sandboxir::Instruction's.
LLVM_ABI void unregisterEraseInstrCallback(CallbackID ID)
LLVM_ABI CallbackID registerEraseInstrCallback(EraseInstrCallback CB)
Register a callback that gets called when a SandboxIR instruction is about to be removed from its par...
A sandboxir::User with operands, opcode and linked with previous/next instructions in an instruction ...
Specialization of SeedBundle for memory access instructions.
A set of candidate Instructions for vectorizing together.
bool isUsed(unsigned Element) const
\Returns whether or not Element has been used.
SmallVector< Instruction * > Seeds
LLVM_ABI ArrayRef< Instruction * > getSlice(unsigned StartIdx, unsigned MaxVecRegBits, bool ForcePowOf2)
\Returns a slice of seed elements, starting at the element StartIdx, with a total size <= MaxVecRegBi...
void setUsed(Instruction *I)
Marks instruction I "used" within the bundle.
LLVM_ABI ~SeedCollector()
LLVM_ABI SeedCollector(BasicBlock *BB, ScalarEvolution &SE, bool CollectStores, bool CollectLoads, bool AllowDiffTypes=false)
void print(raw_ostream &OS) const
LLVM_DUMP_METHOD void dump() const
void print(raw_ostream &OS) const
void insert(LoadOrStoreT *LSI, bool AllowDiffTypes)
LLVM_DUMP_METHOD void dump() const
LLVM_ABI bool erase(Instruction *I)
Just like llvm::Type these are immutable, unique, never get freed and can only be created via static ...
bool isX86_FP80Ty() const
Return true if this is x86 long double.
bool isPPC_FP128Ty() const
Return true if this is powerpc long double.
static unsigned getNumBits(Type *Ty, const DataLayout &DL)
\Returns the number of bits of Ty.
static Type * getExpectedType(const Value *V)
\Returns the expected type of Value V.
static Value * getMemInstructionBase(const LoadOrStoreT *LSI)
\Returns the base Value for load or store instruction LSI.
A SandboxIR Value has users. This is the base class.
static LLVM_ABI bool isValidElementType(Type *ElemTy)
initializer< Ty > init(const Ty &Val)
template bool isValidMemSeed< StoreInst >(StoreInst *LSI)
static bool isValidMemSeed(LoadOrStoreT *LSI)
template bool isValidMemSeed< LoadInst >(LoadInst *LSI)
static cl::opt< unsigned > SeedGroupsLimit("sbvec-seed-groups-limit", cl::init(256), cl::Hidden, cl::desc("Limit the number of collected seeds groups in a BB to " "cap compilation time."))
static cl::opt< unsigned > SeedBundleSizeLimit("sbvec-seed-bundle-size-limit", cl::init(32), cl::Hidden, cl::desc("Limit the size of the seed bundle to cap compilation time."))
This is an optimization pass for GlobalISel generic memory operations.
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.