summaryrefslogtreecommitdiffstats
path: root/polly/lib/Support/ScopHelper.cpp
diff options
context:
space:
mode:
authorEli Friedman <efriedma@codeaurora.org>2016-11-02 22:32:23 +0000
committerEli Friedman <efriedma@codeaurora.org>2016-11-02 22:32:23 +0000
commitacf80064716710a6546282066f4ddd1eeb911f04 (patch)
treeabc37720dab7f2ce35facea5d57911473d413745 /polly/lib/Support/ScopHelper.cpp
parent450338a257b6bc75bf8394f35e35b4b9bc25e761 (diff)
downloadbcm5719-llvm-acf80064716710a6546282066f4ddd1eeb911f04.tar.gz
bcm5719-llvm-acf80064716710a6546282066f4ddd1eeb911f04.zip
[Polly CodeGen] Break critical edge from RTC to original loop.
This makes polly generate a CFG which is closer to what we want in LLVM IR, with a loop preheader for the original loop. This is just a cleanup, but it exposes some fragile assumptions. I'm not completely happy with the changes related to expandCodeFor; RTCBB->getTerminator() is basically a random insertion point which happens to work due to the way we generate runtime checks. I'm not sure what the right answer looks like, though. Differential Revision: https://reviews.llvm.org/D26053 llvm-svn: 285864
Diffstat (limited to 'polly/lib/Support/ScopHelper.cpp')
-rw-r--r--polly/lib/Support/ScopHelper.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/polly/lib/Support/ScopHelper.cpp b/polly/lib/Support/ScopHelper.cpp
index 9e94b9f5740..71e788f8751 100644
--- a/polly/lib/Support/ScopHelper.cpp
+++ b/polly/lib/Support/ScopHelper.cpp
@@ -226,9 +226,10 @@ 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, ValueMapT *VMap)
+ const DataLayout &DL, const char *Name, ValueMapT *VMap,
+ BasicBlock *RTCBB)
: Expander(SCEVExpander(SE, DL, Name)), SE(SE), Name(Name), R(R),
- VMap(VMap) {}
+ VMap(VMap), RTCBB(RTCBB) {}
Value *expandCodeFor(const SCEV *E, Type *Ty, Instruction *I) {
// If we generate code in the region we will immediately fall back to the
@@ -245,6 +246,7 @@ private:
const char *Name;
const Region &R;
ValueMapT *VMap;
+ BasicBlock *RTCBB;
const SCEV *visitGenericInst(const SCEVUnknown *E, Instruction *Inst,
Instruction *IP) {
@@ -280,15 +282,14 @@ private:
return visit(NewE);
}
- auto *EnteringBB = R.getEnteringBlock();
Instruction *Inst = dyn_cast<Instruction>(E->getValue());
Instruction *IP;
if (Inst && !R.contains(Inst))
IP = Inst;
- else if (Inst && EnteringBB->getParent() == Inst->getFunction())
- IP = EnteringBB->getTerminator();
+ else if (Inst && RTCBB->getParent() == Inst->getFunction())
+ IP = RTCBB->getTerminator();
else
- IP = EnteringBB->getParent()->getEntryBlock().getTerminator();
+ IP = RTCBB->getParent()->getEntryBlock().getTerminator();
if (!Inst || (Inst->getOpcode() != Instruction::SRem &&
Inst->getOpcode() != Instruction::SDiv))
@@ -363,8 +364,9 @@ 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);
+ Instruction *IP, ValueMapT *VMap,
+ BasicBlock *RTCBB) {
+ ScopExpander Expander(S.getRegion(), SE, DL, Name, VMap, RTCBB);
return Expander.expandCodeFor(E, Ty, IP);
}
OpenPOWER on IntegriCloud