-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[SandboxVectorizer] Add MemSeed bundle types #111584
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -123,5 +123,35 @@ class SeedBundle { | |
| } | ||
| #endif // NDEBUG | ||
| }; | ||
|
|
||
| template <typename LoadOrStoreT> class MemSeedBundle : public SeedBundle { | ||
| public: | ||
| explicit MemSeedBundle(SmallVector<Instruction *> &&SV, ScalarEvolution &SE) | ||
| : SeedBundle(std::move(SV)) { | ||
| assert(all_of(Seeds, [](auto *S) { return isa<LoadOrStoreT>(S); }) && | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps a static assert?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
| "Expected Load or Store instructions!"); | ||
| auto Cmp = [&SE](Instruction *I0, Instruction *I1) { | ||
| return Utils::atLowerAddress(cast<LoadOrStoreT>(I0), | ||
| cast<LoadOrStoreT>(I1), SE); | ||
| }; | ||
| std::sort(Seeds.begin(), Seeds.end(), Cmp); | ||
| } | ||
| explicit MemSeedBundle(LoadOrStoreT *MemI) : SeedBundle(MemI) { | ||
| assert(isa<LoadOrStoreT>(MemI) && "Expected Load or Store!"); | ||
| } | ||
| void insert(sandboxir::Instruction *I, ScalarEvolution &SE) { | ||
| assert(isa<LoadOrStoreT>(I) && "Expected a Store or a Load!"); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same, static_assert.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
| auto Cmp = [&SE](Instruction *I0, Instruction *I1) { | ||
| return Utils::atLowerAddress(cast<LoadOrStoreT>(I0), | ||
| cast<LoadOrStoreT>(I1), SE); | ||
| }; | ||
| // Find the first element after I in mem. Then insert I before it. | ||
| insertAt(std::upper_bound(begin(), end(), I, Cmp), I); | ||
| } | ||
| }; | ||
|
|
||
| using StoreSeedBundle = MemSeedBundle<sandboxir::StoreInst>; | ||
| using LoadSeedBundle = MemSeedBundle<sandboxir::LoadInst>; | ||
|
|
||
| } // namespace llvm::sandboxir | ||
| #endif // LLVM_TRANSFORMS_VECTORIZE_SANDBOXVECTORIZER_SEEDCOLLECTOR_H | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A brief description comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done