LLVM: lib/Transforms/Vectorize/SandboxVectorizer/Passes/PackReuse.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
11
13
16 return Change;
17
18
21 PacksMap;
22
23 for (auto *I : Rgn) {
25 if (PackOpt) {
26
27 BasicBlock *BB = (*PackOpt->Instrs.front()).getParent();
28 PacksMap[{BB, PackOpt->Operands}].push_back(PackOpt->Instrs);
29 }
30 }
31 for (auto &Pair : PacksMap) {
32 auto &Packs = Pair.second;
33 if (Packs.size() <= 1)
34 continue;
35
36 sort(Packs, [](const auto &PackInstrs1, const auto &PackInstrs2) {
37 return PackInstrs1.front()->comesBefore(PackInstrs2.front());
38 });
39 Instruction *TopMostPack = Packs[0].front();
40
41 for (const auto &PackInstrs :
42 make_range(std::next(Packs.begin()), Packs.end())) {
43 PackInstrs.front()->replaceAllUsesWith(TopMostPack);
44
45 for (auto *PackI : PackInstrs)
46 PackI->eraseFromParent();
47 }
48 Change = true;
49 }
50 return Change;
51}
52
53}
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
A sandboxir::User with operands, opcode and linked with previous/next instructions in an instruction ...
bool runOnRegion(Region &Rgn, const Analyses &A) final
\Returns true if it modifies R.
Definition PackReuse.cpp:14
The main job of the Region is to point to new instructions generated by vectorization passes.
bool empty() const
Returns true if the Region has no instructions.
static std::optional< PackPattern > matchPack(Instruction *I)
If I is the last instruction of a pack pattern (i.e., an InsertElement into a vector),...
BasicBlock(llvm::BasicBlock *BB, Context &SBCtx)
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
void sort(IteratorTy Start, IteratorTy End)