[PATCH] D30103: [SLP] Rework `findBuildAggregate()` from ercursive form to iterative, NFC.

Alexey Bataev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 20 00:01:29 PST 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL295641: [SLP] Rework `findBuildAggregate()` from ercursive form to iterative, NFC. (authored by ABataev).

Changed prior to commit:
  https://reviews.llvm.org/D30103?vs=88915&id=89078#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30103

Files:
  llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp


Index: llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -4614,16 +4614,19 @@
 static bool findBuildAggregate(InsertValueInst *IV,
                                SmallVectorImpl<Value *> &BuildVector,
                                SmallVectorImpl<Value *> &BuildVectorOpds) {
-  if (!IV->hasOneUse())
-    return false;
-  Value *V = IV->getAggregateOperand();
-  if (!isa<UndefValue>(V)) {
-    InsertValueInst *I = dyn_cast<InsertValueInst>(V);
-    if (!I || !findBuildAggregate(I, BuildVector, BuildVectorOpds))
+  Value *V = IV;
+  do {
+    BuildVector.push_back(IV);
+    BuildVectorOpds.push_back(IV->getInsertedValueOperand());
+    V = IV->getAggregateOperand();
+    if (isa<UndefValue>(V))
+      break;
+    IV = dyn_cast<InsertValueInst>(V);
+    if (!IV || !IV->hasOneUse())
       return false;
-  }
-  BuildVector.push_back(IV);
-  BuildVectorOpds.push_back(IV->getInsertedValueOperand());
+  } while (true);
+  std::reverse(BuildVector.begin(), BuildVector.end());
+  std::reverse(BuildVectorOpds.begin(), BuildVectorOpds.end());
   return true;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30103.89078.patch
Type: text/x-patch
Size: 1263 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170220/c735a2d9/attachment.bin>


More information about the llvm-commits mailing list