diff options
author | Arnold Schwaighofer <aschwaighofer@apple.com> | 2013-11-01 22:18:19 +0000 |
---|---|---|
committer | Arnold Schwaighofer <aschwaighofer@apple.com> | 2013-11-01 22:18:19 +0000 |
commit | f4775827d046aa12f6aaffd5bd4746744e8fdff8 (patch) | |
tree | ad74a1bff1264cde016e8dc6c2173d8509ae69df /lib | |
parent | 4b1d68bca9e470d06600fed53e4e16251cac31b6 (diff) | |
download | llvm-f4775827d046aa12f6aaffd5bd4746744e8fdff8.tar.gz llvm-f4775827d046aa12f6aaffd5bd4746744e8fdff8.tar.bz2 llvm-f4775827d046aa12f6aaffd5bd4746744e8fdff8.tar.xz |
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
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193891 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Transforms/Vectorize/LoopVectorize.cpp | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/lib/Transforms/Vectorize/LoopVectorize.cpp b/lib/Transforms/Vectorize/LoopVectorize.cpp index ee94173eb1..7f77784d28 100644 --- a/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/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() { |