[clang] [llvm] [clang][CodeGen] Generate follow-up metadata for loops in correct format (PR #131985)

Ryotaro Kasuga via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 27 18:48:37 PDT 2025


================
@@ -44,23 +44,19 @@ MDNode *LoopInfo::createPipeliningMetadata(const LoopAttributes &Attrs,
   else if (Attrs.PipelineInitiationInterval != 0)
     Enabled = true;
 
+  SmallVector<Metadata *, 4> Args;
+  Args.append(LoopProperties.begin(), LoopProperties.end());
+
   if (Enabled != true) {
-    SmallVector<Metadata *, 4> NewLoopProperties;
     if (Enabled == false) {
-      NewLoopProperties.append(LoopProperties.begin(), LoopProperties.end());
----------------
kasuga-fj wrote:

> In principle, LoopVectorize should know that if the original loop had a progress guarantee, then the vectorized loop will as well, so it should add `llvm.loop.must_progress` no matter what.

I think this is completely correct. What I didn't understand is, why the followup metadata of `LOOP_6` (`FOLLOW_VECTOR_6`) didn't have `llvm.mustprogress` before this patch, but now it (`FOLLOWUP_VECTOR_3`) does.  I investigated a little deeper and found the cause; `FOLLOWUP_VECTOR_6` actually had `mustprogress` (?!). That is, the test passed for both of the following directives.

```
// Original.
// CHECK: ![[AFTER_VECTOR_6]] = distinct !{![[AFTER_VECTOR_6]], ![[ISVECTORIZED:.*]], ![[UNROLL_8:.*]]}

// This was also fine.
// CHECK: ![[AFTER_VECTOR_6]] = distinct !{![[AFTER_VECTOR_6]], [[MP]], ![[ISVECTORIZED:.*]], ![[UNROLL_8:.*]]}
```

Maybe FileCheck has a problem?

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


More information about the llvm-commits mailing list