[polly] [Polly] Retain vectorization for fallback loop when RTC is false (PR #165525)
Karthika Devi C via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 3 03:08:50 PST 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.
----------------
kartcq 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?
>
> Some additional info
Yes, Loop Vectorizer does versioning in cases where RTCs are required.
https://github.com/llvm/llvm-project/pull/165525
More information about the llvm-commits
mailing list