[polly] [Polly] Retain vectorization for fallback loop when RTC is false (PR #165525)

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 3 05:27:46 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.
----------------
Meinersbur wrote:

Could you please clarify the comment? It does not prevent loop versions, it just avoids that both of them do it in the fallback case. In worst case, we still get 3 of them: 'Polly RTC pass, LoopVectorize RTC pass', 'Polly RTC pass, LoopVectorize RTC fail', 'Polly RTC fail, no LoopVectorize' (instead of 4). There is no "Also" (you are using it twice), there is just this motivation.

https://github.com/llvm/llvm-project/pull/165525


More information about the llvm-commits mailing list