[polly] [Polly] Add vectorize metadata to loops identified as vectorizable by polly (PR #113994)

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 5 04:41:55 PST 2024


================
@@ -159,8 +162,20 @@ Value *polly::createLoop(Value *LB, Value *UB, Value *Stride,
 
   // Create the loop latch and annotate it as such.
   BranchInst *B = Builder.CreateCondBr(LoopCondition, HeaderBB, ExitBB);
-  if (Annotator)
-    Annotator->annotateLoopLatch(B, NewLoop, Parallel, LoopVectDisabled);
+
+  // Don't annotate vectorize metadata when both LoopVectDisabled and
+  // PollyVectorizeMetadata are disabled. Annotate vectorize metadata to false
+  // when LoopVectDisabled is true. Otherwise we annotate the vectorize metadata
+  // to true.
+  if (Annotator) {
+    if (!LoopVectDisabled && !PollyVectorizeMetadata)
+      Annotator->annotateLoopLatch(B, Parallel);
+    else
+      Annotator->annotateLoopLatch(
+          B, Parallel,
+          /*EnableVectorizeMetadata*/ !LoopVectDisabled &&
+              PollyVectorizeMetadata);
----------------
Meinersbur wrote:

```suggestion
   std::optional<bool> EnableVectorizeMetadata;
   if (LoopVectDisabled)
     EnableVectorizeMetadata = false;
   else if (PollyVectorizeMetadata)
     EnableVectorizeMetadata = true;
   Annotator->annotateLoopLatch(B, Parallel, EnableVectorizeMetadata);
```
If I got the boolean logic correct

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


More information about the llvm-commits mailing list