Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,8 @@ class SeedCollector {
}

public:
LLVM_ABI SeedCollector(BasicBlock *BB, ScalarEvolution &SE);
LLVM_ABI SeedCollector(BasicBlock *BB, ScalarEvolution &SE,
bool CollectStores, bool CollectLoads);
LLVM_ABI ~SeedCollector();

iterator_range<SeedContainer::iterator> getStoreSeeds() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ static cl::opt<bool>
AllowNonPow2("sbvec-allow-non-pow2", cl::init(false), cl::Hidden,
cl::desc("Allow non-power-of-2 vectorization."));

#define LoadSeedsDef "loads"
#define StoreSeedsDef "stores"
cl::opt<std::string> CollectSeeds(
"sbvec-collect-seeds", cl::init(StoreSeedsDef), cl::Hidden,
cl::desc("Collect these seeds. Use empty for none or a comma-separated "
"list of '" StoreSeedsDef "' and '" LoadSeedsDef "'."));

namespace sandboxir {
SeedCollection::SeedCollection(StringRef Pipeline)
: FunctionPass("seed-collection"),
Expand All @@ -38,10 +45,12 @@ bool SeedCollection::runOnFunction(Function &F, const Analyses &A) {
: A.getTTI()
.getRegisterBitWidth(TargetTransformInfo::RGK_FixedWidthVector)
.getFixedValue();
bool CollectStores = CollectSeeds.find(StoreSeedsDef) != std::string::npos;
bool CollectLoads = CollectSeeds.find(LoadSeedsDef) != std::string::npos;

// TODO: Start from innermost BBs first
for (auto &BB : F) {
SeedCollector SC(&BB, A.getScalarEvolution());
SeedCollector SC(&BB, A.getScalarEvolution(), CollectStores, CollectLoads);
for (SeedBundle &Seeds : SC.getStoreSeeds()) {
unsigned ElmBits =
Utils::getNumBits(VecUtils::getElementType(Utils::getExpectedType(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,7 @@ namespace llvm::sandboxir {
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."));
#define LoadSeedsDef "loads"
#define StoreSeedsDef "stores"
static cl::opt<std::string> CollectSeeds(
"sbvec-collect-seeds", cl::init(LoadSeedsDef "," StoreSeedsDef), cl::Hidden,
cl::desc("Collect these seeds. Use empty for none or a comma-separated "
"list of '" LoadSeedsDef "' and '" StoreSeedsDef "'."));

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 "
Expand Down Expand Up @@ -162,11 +157,10 @@ template <typename LoadOrStoreT> static bool isValidMemSeed(LoadOrStoreT *LSI) {
template bool isValidMemSeed<LoadInst>(LoadInst *LSI);
template bool isValidMemSeed<StoreInst>(StoreInst *LSI);

SeedCollector::SeedCollector(BasicBlock *BB, ScalarEvolution &SE)
SeedCollector::SeedCollector(BasicBlock *BB, ScalarEvolution &SE,
bool CollectStores, bool CollectLoads)
: StoreSeeds(SE), LoadSeeds(SE), Ctx(BB->getContext()) {

bool CollectStores = CollectSeeds.find(StoreSeedsDef) != std::string::npos;
bool CollectLoads = CollectSeeds.find(LoadSeedsDef) != std::string::npos;
if (!CollectStores && !CollectLoads)
return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,8 @@ define void @foo(ptr noalias %ptr, float %val) {
sandboxir::Context Ctx(C);
auto &F = *Ctx.createFunction(&LLVMF);
auto BB = F.begin();
sandboxir::SeedCollector SC(&*BB, SE);
sandboxir::SeedCollector SC(&*BB, SE, /*CollectStores=*/true,
/*CollectLoads=*/false);

// Find the stores
auto It = std::next(BB->begin(), 4);
Expand Down Expand Up @@ -359,7 +360,8 @@ define void @foo(ptr noalias %ptr, float %val) {
sandboxir::Context Ctx(C);
auto &F = *Ctx.createFunction(&LLVMF);
auto BB = F.begin();
sandboxir::SeedCollector SC(&*BB, SE);
sandboxir::SeedCollector SC(&*BB, SE, /*CollectStores=*/true,
/*CollectLoads=*/false);

// Find the stores
auto It = std::next(BB->begin(), 4);
Expand Down Expand Up @@ -419,7 +421,8 @@ define void @foo(ptr noalias %ptr, <2 x float> %val0, i64 %val1) {
sandboxir::Context Ctx(C);
auto &F = *Ctx.createFunction(&LLVMF);
auto BB = F.begin();
sandboxir::SeedCollector SC(&*BB, SE);
sandboxir::SeedCollector SC(&*BB, SE, /*CollectStores=*/true,
/*CollectLoads=*/false);

// Find the stores
auto It = std::next(BB->begin(), 3);
Expand Down Expand Up @@ -460,7 +463,8 @@ define void @foo(ptr noalias %ptr, float %v, <2 x float> %val) {
sandboxir::Context Ctx(C);
auto &F = *Ctx.createFunction(&LLVMF);
auto BB = F.begin();
sandboxir::SeedCollector SC(&*BB, SE);
sandboxir::SeedCollector SC(&*BB, SE, /*CollectStores=*/true,
/*CollectLoads=*/false);

// Find the stores
auto It = std::next(BB->begin(), 3);
Expand Down Expand Up @@ -503,7 +507,8 @@ define void @foo(ptr noalias %ptr, <2 x float> %val0) {
sandboxir::Context Ctx(C);
auto &F = *Ctx.createFunction(&LLVMF);
auto BB = F.begin();
sandboxir::SeedCollector SC(&*BB, SE);
sandboxir::SeedCollector SC(&*BB, SE, /*CollectStores=*/false,
/*CollectLoads=*/true);

// Find the loads
auto It = std::next(BB->begin(), 2);
Expand Down