[llvm] [SLP] Use named structs in vectorizeStores() (NFC) (PR #132781)
Gaëtan Bossu via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 25 01:37:30 PDT 2025
================
@@ -19923,31 +19923,51 @@ bool SLPVectorizerPass::vectorizeStores(
BoUpSLP::ValueSet VectorizedStores;
bool Changed = false;
+ /// A store instruction and the distance of its address to a base pointer.
+ struct CandidateInstr {
+ CandidateInstr(unsigned InstrIdx, int DistToBasePtr)
+ : InstrIdx(InstrIdx), DistToBasePtr(DistToBasePtr) {}
+ unsigned InstrIdx;
+ int DistToBasePtr;
+ };
struct StoreDistCompare {
- bool operator()(const std::pair<unsigned, int> &Op1,
- const std::pair<unsigned, int> &Op2) const {
- return Op1.second < Op2.second;
+ bool operator()(const CandidateInstr &Op1,
+ const CandidateInstr &Op2) const {
+ return Op1.DistToBasePtr < Op2.DistToBasePtr;
}
};
- // A set of pairs (index of store in Stores array ref, Distance of the store
- // address relative to base store address in units).
- using StoreIndexToDistSet =
- std::set<std::pair<unsigned, int>, StoreDistCompare>;
- auto TryToVectorize = [&](const StoreIndexToDistSet &Set) {
+
+ /// A group of store instructions that we'll try to bundle together.
+ /// They are ordered using their signed distance to the address of this
+ /// set's BaseInstr.
+ struct CandidateBundle {
----------------
gbossu wrote:
> `Bundle` is reserved for scheduling model
Agree, I think it's better not to use it. That actually did confuse me when I first saw this word in the SLPVectorizer 😅 I'd still prefer to use a word that describes the intent rather than a word that just gives an implementation detail. What would you think about `ComparableStores`? Reading through the code, I think this is what we use the data structure for: it collects all pointers based off of a same base, and tries to splice that list to create vector ops.
> Also, better to move these structs out of function into the anonymous namespace
Agree again, I just assumed you'd prefer it this way because you seem to prefer lambdas over free functions. I will move the declarations out 🙂
https://github.com/llvm/llvm-project/pull/132781
More information about the llvm-commits
mailing list