summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorArnold Schwaighofer <aschwaighofer@apple.com>2013-11-01 22:18:19 +0000
committerArnold Schwaighofer <aschwaighofer@apple.com>2013-11-01 22:18:19 +0000
commita846a7f8f054d5e7dcb39c4f3c585752e824ebe1 (patch)
tree006fb5e4147c15b7d7c1888bdb8935d3d82fdebc /llvm/lib/Transforms
parented265941d4ef9961c68d02eaf5db2e3f6d1d4654 (diff)
downloadbcm5719-llvm-a846a7f8f054d5e7dcb39c4f3c585752e824ebe1.tar.gz
bcm5719-llvm-a846a7f8f054d5e7dcb39c4f3c585752e824ebe1.zip
LoopVectorizer: Perform redundancy elimination on induction variables
When the loop vectorizer was part of the SCC inliner pass manager gvn would run after the loop vectorizer followed by instcombine. This way redundancy (multiple uses) were removed and instcombine could perform scalarization on the induction variables. Having moved the loop vectorizer to later we no longer run any form of redundancy elimination before we perform instcombine. This caused vectorized induction variables to survive that did not before. On a recent iMac this helps linpack back from 6000Mflops to 7000Mflops. This should also help lpbench and paq8p. I ran a Release (without Asserts) build over the test-suite and did not see any negative impact on compile time. radar://15339680 llvm-svn: 193891
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Vectorize/LoopVectorize.cpp35
1 files changed, 34 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index ee94173eb18..7f77784d282 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -2272,8 +2272,41 @@ InnerLoopVectorizer::vectorizeLoop(LoopVectorizationLegality *Legal) {
(RdxPhi)->setIncomingValue(SelfEdgeBlockIdx, ReducedPartRdx);
(RdxPhi)->setIncomingValue(IncomingEdgeBlockIdx, RdxDesc.LoopExitInstr);
}// end of for each redux variable.
-
+
fixLCSSAPHIs();
+
+ // Perform simple cse.
+ SmallPtrSet<Instruction*, 16> Visited;
+ SmallVector<Instruction*, 16> ToRemove;
+ for (BasicBlock::iterator I = LoopVectorBody->begin(),
+ E = LoopVectorBody->end(); I != E; ++I) {
+ Instruction *In = I;
+
+ if (!isa<InsertElementInst>(In) && !isa<ExtractElementInst>(In) &&
+ !isa<ShuffleVectorInst>(In) && !isa<GetElementPtrInst>(In))
+ continue;
+
+ // Check if we can replace this instruction with any of the
+ // visited instructions.
+ for (SmallPtrSet<Instruction*, 16>::iterator v = Visited.begin(),
+ ve = Visited.end(); v != ve; ++v) {
+ if (In->isIdenticalTo(*v)) {
+ In->replaceAllUsesWith(*v);
+ ToRemove.push_back(In);
+ In = 0;
+ break;
+ }
+ }
+ if (In)
+ Visited.insert(In);
+
+ }
+ // Erase all of the instructions that we RAUWed.
+ for (SmallVectorImpl<Instruction *>::iterator v = ToRemove.begin(),
+ ve = ToRemove.end(); v != ve; ++v) {
+ assert((*v)->getNumUses() == 0 && "Can't remove instructions with uses");
+ (*v)->eraseFromParent();
+ }
}
void InnerLoopVectorizer::fixLCSSAPHIs() {
OpenPOWER on IntegriCloud