[llvm] r295641 - [SLP] Rework `findBuildAggregate()` from ercursive form to iterative, NFC.
Alexey Bataev via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 19 23:49:40 PST 2017
Author: abataev
Date: Mon Feb 20 01:49:39 2017
New Revision: 295641
URL: http://llvm.org/viewvc/llvm-project?rev=295641&view=rev
Log:
[SLP] Rework `findBuildAggregate()` from ercursive form to iterative, NFC.
Reviewers: mkuper
Subscribers: llvm-commits, mzolotukhin
Differential Revision: https://reviews.llvm.org/D30103
Modified:
llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp
Modified: llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp?rev=295641&r1=295640&r2=295641&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp Mon Feb 20 01:49:39 2017
@@ -4614,16 +4614,19 @@ static bool findBuildVector(InsertElemen
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;
}
More information about the llvm-commits
mailing list