[llvm] [LoadStoreVectorizer] Fill gaps in load/store chains to enable vectorization (PR #159388)
Akshay Deodhar via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 5 11:07:42 PST 2025
================
@@ -623,6 +663,25 @@ std::vector<Chain> Vectorizer::splitChainByContiguity(Chain &C) {
dumpChain(C);
});
+ // If the chain is not contiguous, we try to fill the gap with "extra"
+ // elements to artificially make it contiguous, to try to enable
+ // vectorization. We only fill gaps if there is a potentially legal masked
+ // load/store for the target. If later on, we don't end up with a chain that
+ // could be vectorized into a legal masked load/store, the chains with extra
+ // elements will be filtered out in splitChainByAlignment.
+ bool TryFillGaps = shouldAttemptMaskedLoadStore(C);
+
+ unsigned ASPtrBits =
+ DL.getIndexSizeInBits(getLoadStoreAddressSpace(C[0].Inst));
+
+ // Compute the alignment of the leader of the chain (which every stored offset
+ // is based on) using the current first element of the chain. This is
+ // conservative, we may be able to derive better alignment by iterating over
+ // the chain and finding the leader.
+ Align LeaderOfChainAlign =
----------------
akshayrdeodhar wrote:
Nice!
> To be specific, this alignment deriving is only useful in the rare event where an extra element ends up as the leader of a chain
Is it possible that InferAlignment proves that an element other than the leader has the best alignment, and it doesn't end up as the leader of the chain.
Regardless, no further change is needed imo.
https://github.com/llvm/llvm-project/pull/159388
More information about the llvm-commits
mailing list