[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
Wed Oct 30 05:33:56 PDT 2024


================
@@ -159,8 +162,19 @@ 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);
+
+  // If the 'polly-annotate-metadata-vectorize' flag is passed, we add
+  // the vectorize metadata. Otherwise we fall back to previous behavior
+  // of annotating the loop only when LoopVectDisabled is true.
+  if (Annotator) {
+    if (PollyVectorizeMetadata)
+      Annotator->annotateLoopLatch(B, NewLoop, Parallel, true,
+                                   !LoopVectDisabled);
+    else if (LoopVectDisabled)
+      Annotator->annotateLoopLatch(B, NewLoop, Parallel, true, false);
----------------
Meinersbur wrote:

```suggestion
      Annotator->annotateLoopLatch(B, NewLoop, Parallel, /*SetVectorizeMetadata=*/true,  /*EnableLoopVectorizer=*/false);
```

but why not:
```cpp
if (Annotator)
   Annotator->annotateLoopLatch(B, NewLoop, Parallel, /*SetVectorizeMetadata=*/PollyVectorizeMetadata||LoopVectDisabled,  /*EnableLoopVectorizer=*/!LoopVectDisabled&&!PollyVectorizeMetadata);
```

or at least

```cpp
else
   Annotator->annotateLoopLatch(B, NewLoop, Parallel, /*SetVectorizeMetadata=*/LoopVectDisabled,  /*EnableLoopVectorizer=*/false);
```

like before this commit

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


More information about the llvm-commits mailing list