diff options
| author | Tobias Grosser <grosser@fim.uni-passau.de> | 2013-03-20 22:41:53 +0000 |
|---|---|---|
| committer | Tobias Grosser <grosser@fim.uni-passau.de> | 2013-03-20 22:41:53 +0000 |
| commit | 5bfa4f8eb82585ea7a2ec049ba67592c1092a417 (patch) | |
| tree | 4faf2bf9f0a9916bcc86f0aa9e8cfd09d0b09186 /polly/lib/CodePreparation.cpp | |
| parent | cd4ebb763913aba062a6604595266060ca33a5da (diff) | |
| download | bcm5719-llvm-5bfa4f8eb82585ea7a2ec049ba67592c1092a417.tar.gz bcm5719-llvm-5bfa4f8eb82585ea7a2ec049ba67592c1092a417.zip | |
CodePrepare: Do not require canonical induction variables for scev based mode
llvm-svn: 177593
Diffstat (limited to 'polly/lib/CodePreparation.cpp')
| -rw-r--r-- | polly/lib/CodePreparation.cpp | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/polly/lib/CodePreparation.cpp b/polly/lib/CodePreparation.cpp index b1d48e04bda..b954e101929 100644 --- a/polly/lib/CodePreparation.cpp +++ b/polly/lib/CodePreparation.cpp @@ -13,6 +13,7 @@ // //===----------------------------------------------------------------------===// #include "polly/LinkAllPasses.h" +#include "polly/CodeGen/BlockGenerators.h" #include "polly/Support/ScopHelper.h" #include "llvm/IR/Instruction.h" @@ -47,6 +48,7 @@ class CodePreparation : public FunctionPass { // LoopInfo to compute canonical induction variable. LoopInfo *LI; + ScalarEvolution *SE; // Clear the context. void clear(); @@ -92,11 +94,21 @@ bool CodePreparation::eliminatePHINodes(Function &F) { for (BasicBlock::iterator iib = ibb->begin(), iie = ibb->getFirstNonPHI(); iib != iie; ++iib) if (PHINode *PN = cast<PHINode>(iib)) { - if (Loop *L = LI->getLoopFor(ibb)) { - // Induction variable will be preserved. - if (L->getCanonicalInductionVariable() == PN) { - PreservedPNs.push_back(PN); - continue; + if (SCEVCodegen) { + if (SE->isSCEVable(PN->getType())) { + const SCEV *S = SE->getSCEV(PN); + if (!isa<SCEVUnknown>(S) && !isa<SCEVCouldNotCompute>(S)) { + PreservedPNs.push_back(PN); + continue; + } + } + } else { + if (Loop *L = LI->getLoopFor(ibb)) { + // Induction variable will be preserved. + if (L->getCanonicalInductionVariable() == PN) { + PreservedPNs.push_back(PN); + continue; + } } } @@ -136,6 +148,7 @@ bool CodePreparation::eliminatePHINodes(Function &F) { void CodePreparation::getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired<LoopInfo>(); + AU.addRequired<ScalarEvolution>(); AU.addPreserved<LoopInfo>(); AU.addPreserved<RegionInfo>(); @@ -145,6 +158,7 @@ void CodePreparation::getAnalysisUsage(AnalysisUsage &AU) const { bool CodePreparation::runOnFunction(Function &F) { LI = &getAnalysis<LoopInfo>(); + SE = &getAnalysis<ScalarEvolution>(); splitEntryBlockForAlloca(&F.getEntryBlock(), this); |

