[PATCH] D26962: [LoadStoreVectorizer] Split the chain if the prefix is empty

Volkan Keles via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 22 04:03:20 PST 2016


volkan created this revision.
volkan added reviewers: jlebar, asbirlea, arsenm.
volkan added a subscriber: llvm-commits.
Herald added subscribers: wdng, mzolotukhin.

Currently, the vectorizer discards all of the instructions in the chain if
the vectorizable prefix is empty. Instead, we can try to vectorize smaller
chunks in order to increase the number of vector instructions generated.


https://reviews.llvm.org/D26962

Files:
  lib/Transforms/Vectorize/LoadStoreVectorizer.cpp


Index: lib/Transforms/Vectorize/LoadStoreVectorizer.cpp
===================================================================
--- lib/Transforms/Vectorize/LoadStoreVectorizer.cpp
+++ lib/Transforms/Vectorize/LoadStoreVectorizer.cpp
@@ -737,9 +737,18 @@
 
   ArrayRef<Instruction *> NewChain = getVectorizablePrefix(Chain);
   if (NewChain.empty()) {
-    // No vectorization possible.
-    InstructionsProcessed->insert(Chain.begin(), Chain.end());
-    return false;
+    // No vectorization possible if the number of instructions
+    // is less than or equal to VF.
+    if (ChainSize <= VF) {
+      InstructionsProcessed->insert(Chain.begin(), Chain.end());
+      return false;
+    }
+    // Split the chain and try each slice seperately in order
+    // to increase the number of vector instructions generated.
+    ArrayRef<Instruction *> Left = Chain.slice(0, VF);
+    ArrayRef<Instruction *> Right = Chain.slice(VF);
+    return vectorizeStoreChain(Left, InstructionsProcessed) |
+           vectorizeStoreChain(Right, InstructionsProcessed);
   }
   if (NewChain.size() == 1) {
     // Failed after the first instruction. Discard it and try the smaller chain.
@@ -885,9 +894,18 @@
 
   ArrayRef<Instruction *> NewChain = getVectorizablePrefix(Chain);
   if (NewChain.empty()) {
-    // No vectorization possible.
-    InstructionsProcessed->insert(Chain.begin(), Chain.end());
-    return false;
+    // No vectorization possible if the number of instructions
+    // is less than or equal to VF.
+    if (ChainSize <= VF) {
+      InstructionsProcessed->insert(Chain.begin(), Chain.end());
+      return false;
+    }
+    // Split the chain and try each slice seperately in order
+    // to increase the number of vector instructions generated.
+    ArrayRef<Instruction *> Left = Chain.slice(0, VF);
+    ArrayRef<Instruction *> Right = Chain.slice(VF);
+    return vectorizeLoadChain(Left, InstructionsProcessed) |
+           vectorizeLoadChain(Right, InstructionsProcessed);
   }
   if (NewChain.size() == 1) {
     // Failed after the first instruction. Discard it and try the smaller chain.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26962.78847.patch
Type: text/x-patch
Size: 2110 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161122/9d11495a/attachment.bin>


More information about the llvm-commits mailing list