aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms/Vectorize/SLPVectorizer.cpp
diff options
context:
space:
mode:
authorNadav Rotem <nrotem@apple.com>2013-06-23 21:57:27 +0000
committerNadav Rotem <nrotem@apple.com>2013-06-23 21:57:27 +0000
commit722b0a4d293b16eebaed94ae65d5f11743cbcea5 (patch)
treea8c2209653dfad4d2f5d9a5e8c0ad92e1878f454 /lib/Transforms/Vectorize/SLPVectorizer.cpp
parent787ad64b989937e0d79e176b0bf9af4a85a839d0 (diff)
downloadexternal_llvm-722b0a4d293b16eebaed94ae65d5f11743cbcea5.tar.gz
external_llvm-722b0a4d293b16eebaed94ae65d5f11743cbcea5.tar.bz2
external_llvm-722b0a4d293b16eebaed94ae65d5f11743cbcea5.zip
SLP Vectorizer: Fix a bug in the code that does CSE on the generated gather sequences.
Make sure that we don't replace and RAUW two sequences if one does not dominate the other. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184674 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Vectorize/SLPVectorizer.cpp')
-rw-r--r--lib/Transforms/Vectorize/SLPVectorizer.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/Transforms/Vectorize/SLPVectorizer.cpp b/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 838cb9599c..5bc3d852e7 100644
--- a/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -127,8 +127,9 @@ public:
static const int MAX_COST = INT_MIN;
FuncSLP(Function *Func, ScalarEvolution *Se, DataLayout *Dl,
- TargetTransformInfo *Tti, AliasAnalysis *Aa, LoopInfo *Li) :
- F(Func), SE(Se), DL(Dl), TTI(Tti), AA(Aa), LI(Li),
+ TargetTransformInfo *Tti, AliasAnalysis *Aa, LoopInfo *Li,
+ DominatorTree *Dt) :
+ F(Func), SE(Se), DL(Dl), TTI(Tti), AA(Aa), LI(Li), DT(Dt),
Builder(Se->getContext()) {
for (Function::iterator it = F->begin(), e = F->end(); it != e; ++it) {
BasicBlock *BB = it;
@@ -255,6 +256,7 @@ public:
TargetTransformInfo *TTI;
AliasAnalysis *AA;
LoopInfo *LI;
+ DominatorTree *DT;
/// Instruction builder to construct the vectorized tree.
IRBuilder<> Builder;
};
@@ -1197,7 +1199,8 @@ void FuncSLP::optimizeGatherSequence() {
// visited instructions.
for (SmallPtrSet<Instruction*, 16>::iterator v = Visited.begin(),
ve = Visited.end(); v != ve; ++v) {
- if (Insert->isIdenticalTo(*v)) {
+ if (Insert->isIdenticalTo(*v) &&
+ DT->dominates((*v)->getParent(), Insert->getParent())) {
Insert->replaceAllUsesWith(*v);
break;
}
@@ -1224,6 +1227,7 @@ struct SLPVectorizer : public FunctionPass {
TargetTransformInfo *TTI;
AliasAnalysis *AA;
LoopInfo *LI;
+ DominatorTree *DT;
virtual bool runOnFunction(Function &F) {
SE = &getAnalysis<ScalarEvolution>();
@@ -1231,6 +1235,7 @@ struct SLPVectorizer : public FunctionPass {
TTI = &getAnalysis<TargetTransformInfo>();
AA = &getAnalysis<AliasAnalysis>();
LI = &getAnalysis<LoopInfo>();
+ DT = &getAnalysis<DominatorTree>();
StoreRefs.clear();
bool Changed = false;
@@ -1244,7 +1249,7 @@ struct SLPVectorizer : public FunctionPass {
// Use the bollom up slp vectorizer to construct chains that start with
// he store instructions.
- FuncSLP R(&F, SE, DL, TTI, AA, LI);
+ FuncSLP R(&F, SE, DL, TTI, AA, LI, DT);
for (Function::iterator it = F.begin(), e = F.end(); it != e; ++it) {
BasicBlock *BB = it;
@@ -1274,6 +1279,7 @@ struct SLPVectorizer : public FunctionPass {
AU.addRequired<AliasAnalysis>();
AU.addRequired<TargetTransformInfo>();
AU.addRequired<LoopInfo>();
+ AU.addRequired<DominatorTree>();
}
private: