23 unsigned MaxVecRegBits,
36 assert(!
isUsed(StartIdx) &&
"Expected unused at StartIdx");
40 if (
isUsed(StartIdx + NumElements))
44 if (BitCount + InstBits > MaxVecRegBits)
49 NumElementsPowerOfTwo = NumElements;
50 BitCountPowerOfTwo = BitCount;
54 NumElements = NumElementsPowerOfTwo;
55 BitCount = BitCountPowerOfTwo;
59 if (NumElements > 1) {
61 "Must be a power of two");
67template <
typename LoadOrStoreT>
68SeedContainer::KeyT SeedContainer::getKey(LoadOrStoreT *LSI,
69 bool AllowDiffTypes)
const {
71 "Expected Load or Store!");
80 Ty = VTy->getElementType();
86template SeedContainer::KeyT
87SeedContainer::getKey<LoadInst>(
LoadInst *LSI,
bool AllowDiffTypes)
const;
88template SeedContainer::KeyT
89SeedContainer::getKey<StoreInst>(
StoreInst *LSI,
bool AllowDiffTypes)
const;
93 auto It = SeedLookupMap.find(
I);
94 if (It == SeedLookupMap.end())
103 BundleSizeLimit = Opts.sbvec_seed_bundle_size_limit;
106template <
typename LoadOrStoreT>
109 auto &
BundleVec = Bundles[getKey(LSI, AllowDiffTypes)];
118 SeedLookupMap[LSI] =
BundleVec.back().get();
129 for (
const auto &Pair : Bundles) {
130 auto [
I, Ty,
Opc] = Pair.first;
131 const auto &SeedsVec = Pair.second;
135 OS <<
"[Inst=" << *
I <<
" Ty=" << Ty <<
" " << RefType <<
"]\n";
136 for (
const auto &SeedPtr : SeedsVec) {
148 if (!LSI->isSimple())
152 if (Ty->isX86_FP80Ty() || Ty->isPPC_FP128Ty())
166 bool CollectStores,
bool CollectLoads,
168 : StoreSeeds(SE), LoadSeeds(SE), Ctx(BB->
getContext()) {
170 if (!CollectStores && !CollectLoads)
173 EraseCallbackID = Ctx.registerEraseInstrCallback([
this](
Instruction *
I) {
175 StoreSeeds.erase(
SI);
182 for (
auto &
I : *BB) {
185 StoreSeeds.insert(
SI, AllowDiffTypes);
188 LoadSeeds.insert(LI, AllowDiffTypes);
190 if (totalNumSeedGroups() > Opts.sbvec_seed_groups_limit)
196 Ctx.unregisterEraseInstrCallback(EraseCallbackID);
201 OS <<
"=== StoreSeeds ===\n";
202 StoreSeeds.print(OS);
203 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
Represent a constant reference to an array (0 or more elements consecutively in memory),...
The main scalar evolution driver.
This class implements an extremely fast bulk output stream that can only output to a stream.
This is a simple bottom-up (top-down) vectorizer Region pass.
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_ABI SeedContainer(ScalarEvolution &SE)
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 ...
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)
Context & getContext() const
template bool isValidMemSeed< StoreInst >(StoreInst *LSI)
static bool isValidMemSeed(LoadOrStoreT *LSI)
BasicBlock(llvm::BasicBlock *BB, Context &SBCtx)
template bool isValidMemSeed< LoadInst >(LoadInst *LSI)
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.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
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.
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
DWARFExpression::Operation Op
const VectorizeOptions & getVectorizeOptions(const LLVMContext &C)