summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--polly/lib/CodeGen/BlockGenerators.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/polly/lib/CodeGen/BlockGenerators.cpp b/polly/lib/CodeGen/BlockGenerators.cpp
index 6f26d51dcaa..260ad6ee9c6 100644
--- a/polly/lib/CodeGen/BlockGenerators.cpp
+++ b/polly/lib/CodeGen/BlockGenerators.cpp
@@ -91,9 +91,12 @@ Value *BlockGenerator::trySynthesizeNewValue(ScopStmt &Stmt, Value *Old,
Value *BlockGenerator::getNewValue(ScopStmt &Stmt, Value *Old, ValueMapT &BBMap,
LoopToScevMapT &LTS, Loop *L) const {
- // We assume constants never change.
- // This avoids map lookups for many calls to this function.
- if (isa<Constant>(Old))
+ // Constants that do not reference any named value can always remain
+ // unchanged. Handle them early to avoid expensive map loopups. We do not take
+ // the fast-path for external constants which are referenced through globals
+ // as these may need to be rewritten when distributing code accross different
+ // LLVM modules.
+ if (isa<Constant>(Old) && !isa<GlobalValue>(Old))
return Old;
if (Value *New = GlobalMap.lookup(Old)) {
OpenPOWER on IntegriCloud