aboutsummaryrefslogtreecommitdiff
path: root/polly/lib/CodeGen
diff options
context:
space:
mode:
Diffstat (limited to 'polly/lib/CodeGen')
-rw-r--r--polly/lib/CodeGen/CodeGeneration.cpp24
1 files changed, 15 insertions, 9 deletions
diff --git a/polly/lib/CodeGen/CodeGeneration.cpp b/polly/lib/CodeGen/CodeGeneration.cpp
index 2d8b393..062cdfb 100644
--- a/polly/lib/CodeGen/CodeGeneration.cpp
+++ b/polly/lib/CodeGen/CodeGeneration.cpp
@@ -235,15 +235,6 @@ static bool generateCode(Scop &S, IslAstInfo &AI, LoopInfo &LI,
NodeBuilder.allocateNewArrays(StartExitBlocks);
Annotator.buildAliasScopes(S);
- // The code below annotates the "llvm.loop.vectorize.enable" to false
- // for the code flow taken when RTCs fail. Because we don't want the
- // Loop Vectorizer to come in later and vectorize the original fall back
- // loop when Polly is enabled.
- for (Loop *L : LI.getLoopsInPreorder()) {
- if (S.contains(L))
- addStringMetadataToLoop(L, "llvm.loop.vectorize.enable", 0);
- }
-
if (PerfMonitoring) {
PerfMonitor P(S, EnteringBB->getParent()->getParent());
P.initialize();
@@ -285,6 +276,21 @@ static bool generateCode(Scop &S, IslAstInfo &AI, LoopInfo &LI,
Builder.GetInsertBlock()->getTerminator()->setOperand(0, RTC);
+ auto *CI = dyn_cast<ConstantInt>(RTC);
+ // The code below annotates the "llvm.loop.vectorize.enable" to false
+ // for the code flow taken when RTCs fail. Because we don't want the
+ // Loop Vectorizer to come in later and vectorize the original fall back
+ // loop when Polly is enabled. This avoids loop versioning on fallback
+ // loop by Loop Vectorizer. Don't do this when Polly's RTC value is
+ // false (due to code generation failure), as we are left with only one
+ // version of Loop.
+ if (!(CI && CI->isZero())) {
+ for (Loop *L : LI.getLoopsInPreorder()) {
+ if (S.contains(L))
+ addStringMetadataToLoop(L, "llvm.loop.vectorize.enable", 0);
+ }
+ }
+
// Explicitly set the insert point to the end of the block to avoid that a
// split at the builder's current
// insert position would move the malloc calls to the wrong BasicBlock.