summaryrefslogtreecommitdiffstats
path: root/polly/lib/CodeGen/CodeGeneration.cpp
diff options
context:
space:
mode:
authorTobias Grosser <grosser@fim.uni-passau.de>2012-04-01 16:49:45 +0000
committerTobias Grosser <grosser@fim.uni-passau.de>2012-04-01 16:49:45 +0000
commit89339067b017733a19812ddbe86b288c8558433f (patch)
tree4143c747eef66be2747483ee58af348ef717a19f /polly/lib/CodeGen/CodeGeneration.cpp
parent12af4285d19c9d50453d243e0fe7f78418288372 (diff)
downloadbcm5719-llvm-89339067b017733a19812ddbe86b288c8558433f.tar.gz
bcm5719-llvm-89339067b017733a19812ddbe86b288c8558433f.zip
CodeGen: Allow function parameters to be rewritten in getNewValue()
When deriving new values for the statements of a SCoP, we assumed that parameter values are constant within the SCoP and consquently do not need to be rewritten. For OpenMP code generation this assumption is wrong, as such values are not available in the OpenMP subfunction and consequently also may need to be rewritten. Committed with some changes. Contributed-By: Johannes Doerfert <s9jodoer@stud.uni-saarland.de> llvm-svn: 153838
Diffstat (limited to 'polly/lib/CodeGen/CodeGeneration.cpp')
-rw-r--r--polly/lib/CodeGen/CodeGeneration.cpp26
1 files changed, 15 insertions, 11 deletions
diff --git a/polly/lib/CodeGen/CodeGeneration.cpp b/polly/lib/CodeGen/CodeGeneration.cpp
index 69f27c00758..8714251f7c1 100644
--- a/polly/lib/CodeGen/CodeGeneration.cpp
+++ b/polly/lib/CodeGen/CodeGeneration.cpp
@@ -283,12 +283,11 @@ BlockGenerator::BlockGenerator(IRBuilder<> &B, ScopStmt &Stmt, Pass *P):
Value *BlockGenerator::getNewValue(const Value *Old, ValueMapT &BBMap,
ValueMapT &GlobalMap) {
- const Instruction *Inst = dyn_cast<Instruction>(Old);
-
- if (!Inst)
+ // We assume constants never change.
+ // This avoids map lookups for many calls to this function.
+ if (isa<Constant>(Old))
return const_cast<Value*>(Old);
- // OldOperand was redefined outside of this BasicBlock.
if (GlobalMap.count(Old)) {
Value *New = GlobalMap[Old];
@@ -299,17 +298,22 @@ Value *BlockGenerator::getNewValue(const Value *Old, ValueMapT &BBMap,
return New;
}
- // OldOperand was recalculated within this BasicBlock.
if (BBMap.count(Old)) {
return BBMap[Old];
}
- // OldOperand is SCoP invariant.
- if (!Statement.getParent()->getRegion().contains(Inst->getParent()))
- return const_cast<Value*>(Old);
-
- // We could not find any valid new operand.
- return NULL;
+ // 'Old' is within the original SCoP, but was not rewritten.
+ //
+ // Such values appear, if they only calculate information already available in
+ // the polyhedral description (e.g. an induction variable increment). They
+ // can be safely ignored.
+ if (const Instruction *Inst = dyn_cast<Instruction>(Old))
+ if (Statement.getParent()->getRegion().contains(Inst->getParent()))
+ return NULL;
+
+ // Everything else is probably a scop-constant value defined as global,
+ // function parameter or an instruction not within the scop.
+ return const_cast<Value*>(Old);
}
void BlockGenerator::copyInstScalar(const Instruction *Inst, ValueMapT &BBMap,
OpenPOWER on IntegriCloud