[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:10:52 PST 2025


================
@@ -831,7 +930,63 @@ std::vector<Chain> Vectorizer::splitChainByAlignment(Chain &C) {
         }
       }
 
-      if (!IsAllowedAndFast(Alignment)) {
+      // The vectorizer does not support non-power-of-2 element count vectors.
+      // Extend the chain to the next power-of-2 if the current chain:
+      //  1. Does not have a power-of-2 element count
+      //  2. Would be legal to vectorize if the element count was extended to
+      //     the next power-of-2
+      Chain ExtendingLoadsStores;
+      if (NumVecElems < TargetVF && !isPowerOf2_32(NumVecElems) &&
+          VecElemBits >= 8 && isPowerOf2_32(TargetVF)) {
----------------
akshayrdeodhar wrote:

If we have an assert that TargetVF is a power of 2, we could get rid of the last check. 

https://github.com/llvm/llvm-project/pull/159388


More information about the llvm-commits mailing list