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 {
79 "Expected Load or Store!");
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;
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;
138 OS <<
"[Inst=" << *
I <<
" Ty=" << Ty <<
" " << RefType <<
"]\n";
139 for (
const auto &SeedPtr : SeedsVec) {
151 if (!LSI->isSimple())
155 if (Ty->isX86_FP80Ty() || Ty->isPPC_FP128Ty())
169 bool CollectStores,
bool CollectLoads,
171 : StoreSeeds(SE), LoadSeeds(SE), Ctx(BB->
getContext()) {
173 if (!CollectStores && !CollectLoads)
176 EraseCallbackID = Ctx.registerEraseInstrCallback([
this](
Instruction *
I) {
178 StoreSeeds.erase(
SI);
184 for (
auto &
I : *BB) {
187 StoreSeeds.insert(
SI, AllowDiffTypes);
190 LoadSeeds.insert(LI, AllowDiffTypes);
198 Ctx.unregisterEraseInstrCallback(EraseCallbackID);
203 OS <<
"=== StoreSeeds ===\n";
204 StoreSeeds.print(OS);
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),...
The main scalar evolution driver.
This class implements an extremely fast bulk output stream that can only output to a stream.
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 ...
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)
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)
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.
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
ArrayRef(const T &OneElt) -> ArrayRef< T >