diff options
author | Johannes Doerfert <doerfert@cs.uni-saarland.de> | 2015-09-30 16:52:03 +0000 |
---|---|---|
committer | Johannes Doerfert <doerfert@cs.uni-saarland.de> | 2015-09-30 16:52:03 +0000 |
commit | c0729a3216dfcb230d44f72155f458fba6702ce5 (patch) | |
tree | 9dac864d1a31fbc2ae4005a39db577711a4e8e26 /polly/lib/Support/ScopHelper.cpp | |
parent | 6206d7a67c7ebfa9408c6d8ae655d7d901bd0862 (diff) | |
download | bcm5719-llvm-c0729a3216dfcb230d44f72155f458fba6702ce5.tar.gz bcm5719-llvm-c0729a3216dfcb230d44f72155f458fba6702ce5.zip |
Move remapping functionality in the ScopExpander
Because we handle more than SCEV does it is not possible to rewrite an
expression on the top-level using the SCEVParameterRewriter only. With
this patch we will do the rewriting on demand only and also
recursively, thus not only on the top-level.
llvm-svn: 248916
Diffstat (limited to 'polly/lib/Support/ScopHelper.cpp')
-rw-r--r-- | polly/lib/Support/ScopHelper.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/polly/lib/Support/ScopHelper.cpp b/polly/lib/Support/ScopHelper.cpp index c55a4749314..70c1f13047e 100644 --- a/polly/lib/Support/ScopHelper.cpp +++ b/polly/lib/Support/ScopHelper.cpp @@ -235,8 +235,9 @@ struct ScopExpander : SCEVVisitor<ScopExpander, const SCEV *> { friend struct SCEVVisitor<ScopExpander, const SCEV *>; explicit ScopExpander(const Region &R, ScalarEvolution &SE, - const DataLayout &DL, const char *Name) - : Expander(SCEVExpander(SE, DL, Name)), SE(SE), Name(Name), R(R) {} + const DataLayout &DL, const char *Name, ValueMapT *VMap) + : Expander(SCEVExpander(SE, DL, Name)), SE(SE), Name(Name), R(R), + VMap(VMap) {} Value *expandCodeFor(const SCEV *E, Type *Ty, Instruction *I) { // If we generate code in the region we will immediately fall back to the @@ -252,8 +253,15 @@ private: ScalarEvolution &SE; const char *Name; const Region &R; + ValueMapT *VMap; const SCEV *visitUnknown(const SCEVUnknown *E) { + + // If a value mapping was given try if the underlying value is remapped. + if (VMap) + if (Value *NewVal = VMap->lookup(E->getValue())) + return visit(SE.getSCEV(NewVal)); + Instruction *Inst = dyn_cast<Instruction>(E->getValue()); if (!Inst || (Inst->getOpcode() != Instruction::SRem && Inst->getOpcode() != Instruction::SDiv)) @@ -327,8 +335,8 @@ private: Value *polly::expandCodeFor(Scop &S, ScalarEvolution &SE, const DataLayout &DL, const char *Name, const SCEV *E, Type *Ty, - Instruction *IP) { - ScopExpander Expander(S.getRegion(), SE, DL, Name); + Instruction *IP, ValueMapT *VMap) { + ScopExpander Expander(S.getRegion(), SE, DL, Name, VMap); return Expander.expandCodeFor(E, Ty, IP); } |