summaryrefslogtreecommitdiffstats
path: root/polly/lib/Support/ScopHelper.cpp
diff options
context:
space:
mode:
authorJohannes Doerfert <doerfert@cs.uni-saarland.de>2016-04-08 18:16:58 +0000
committerJohannes Doerfert <doerfert@cs.uni-saarland.de>2016-04-08 18:16:58 +0000
commit5155edc6583aee9264a94abf2c43dca936669d0c (patch)
treef11b254b60c1a6a984564ef369ec71c7a10ef8de /polly/lib/Support/ScopHelper.cpp
parenta9dc5294420749b12def8f5bb6dda675598f1376 (diff)
downloadbcm5719-llvm-5155edc6583aee9264a94abf2c43dca936669d0c.tar.gz
bcm5719-llvm-5155edc6583aee9264a94abf2c43dca936669d0c.zip
[FIX] Teach the ScopExpander about parallel subfunctions
llvm-svn: 265824
Diffstat (limited to 'polly/lib/Support/ScopHelper.cpp')
-rw-r--r--polly/lib/Support/ScopHelper.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/polly/lib/Support/ScopHelper.cpp b/polly/lib/Support/ScopHelper.cpp
index e73946f5042..469c00d52d3 100644
--- a/polly/lib/Support/ScopHelper.cpp
+++ b/polly/lib/Support/ScopHelper.cpp
@@ -225,9 +225,9 @@ void polly::splitEntryBlockForAlloca(BasicBlock *EntryBlock, Pass *P) {
struct ScopExpander : SCEVVisitor<ScopExpander, const SCEV *> {
friend struct SCEVVisitor<ScopExpander, const SCEV *>;
- explicit ScopExpander(const Region &R, ScalarEvolution &SE,
+ explicit ScopExpander(const Region &R, Function &F, ScalarEvolution &SE,
const DataLayout &DL, const char *Name, ValueMapT *VMap)
- : Expander(SCEVExpander(SE, DL, Name)), SE(SE), Name(Name), R(R),
+ : Expander(SCEVExpander(SE, DL, Name)), F(F), SE(SE), Name(Name), R(R),
VMap(VMap) {}
Value *expandCodeFor(const SCEV *E, Type *Ty, Instruction *I) {
@@ -241,6 +241,10 @@ struct ScopExpander : SCEVVisitor<ScopExpander, const SCEV *> {
private:
SCEVExpander Expander;
+
+ /// @brief The function in which the code is placed.
+ Function &F;
+
ScalarEvolution &SE;
const char *Name;
const Region &R;
@@ -264,10 +268,15 @@ private:
Inst->getOpcode() != Instruction::SDiv))
return E;
- if (!R.contains(Inst))
+ // If the instruction is outside the SCoP we can just use it without the
+ // need to recompute it. However, if it is in another function we need to
+ // recompute it as the definition does not dominate the use.
+ bool SameFunction = (&F == R.getEntry()->getParent());
+ if (!R.contains(Inst) && SameFunction)
return E;
- Instruction *StartIP = R.getEnteringBlock()->getTerminator();
+ Instruction *StartIP = SameFunction ? R.getEnteringBlock()->getTerminator()
+ : F.getEntryBlock().getTerminator();
const SCEV *LHSScev = visit(SE.getSCEV(Inst->getOperand(0)));
const SCEV *RHSScev = visit(SE.getSCEV(Inst->getOperand(1)));
@@ -333,7 +342,7 @@ private:
Value *polly::expandCodeFor(Scop &S, ScalarEvolution &SE, const DataLayout &DL,
const char *Name, const SCEV *E, Type *Ty,
Instruction *IP, ValueMapT *VMap) {
- ScopExpander Expander(S.getRegion(), SE, DL, Name, VMap);
+ ScopExpander Expander(S.getRegion(), *IP->getFunction(), SE, DL, Name, VMap);
return Expander.expandCodeFor(E, Ty, IP);
}
OpenPOWER on IntegriCloud