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


================
@@ -831,7 +914,60 @@ std::vector<Chain> Vectorizer::splitChainByAlignment(Chain &C) {
         }
       }
 
-      if (!IsAllowedAndFast(Alignment)) {
+      // Attempt to extend non-power-of-2 chains to the next power of 2.
+      Chain ExtendingLoadsStores;
+      if (NumVecElems < TargetVF && NumVecElems % 2 != 0 && VecElemBits >= 8) {
+        // TargetVF may be a lot higher than NumVecElems,
+        // so only extend to the next power of 2.
+        assert(VecElemBits % 8 == 0);
+        unsigned VecElemBytes = VecElemBits / 8;
+        unsigned NewNumVecElems = PowerOf2Ceil(NumVecElems);
+        unsigned NewSizeBytes = VecElemBytes * NewNumVecElems;
+
+        assert(NewNumVecElems <= TargetVF);
----------------
akshayrdeodhar wrote:

Perhaps make this explicit? 
> Yes, that is what is being implicitly asserted.

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


More information about the llvm-commits mailing list