[polly] [Polly] Retain vectorization for fallback loop when RTC is false (PR #165525)
Michael Kruse via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 30 07:27:12 PDT 2025
================
@@ -282,9 +273,22 @@ static bool generateCode(Scop &S, IslAstInfo &AI, LoopInfo &LI,
} else {
NodeBuilder.addParameters(S.getContext().release());
Value *RTC = NodeBuilder.createRTC(AI.getRunCondition().release());
-
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 also prevent's multiple loop versions
+ // created by Polly with Loop Vectorizer. Also don't do this when Polly's
+ // RTC value is false, as we are left with only one version of Loop.
----------------
Meinersbur wrote:
> This also prevent's multiple loop versions created by Polly with Loop Vectorizer
I don't understand this part. Do you mean the loop versioning that LoopVectorize does in addition to the one Polly already did?
```suggestion
// loop when Polly is enabled. This also prevent's multiple loop versions
// created by Polly with Loop Vectorizer. Also don't do this when Polly's
// RTC value is false (which may be the result of code generation having failed), as we are left with only one version of Loop.
```
Some additional info
https://github.com/llvm/llvm-project/pull/165525
More information about the llvm-commits
mailing list