[llvm] [llvm][Verifier] Ensure we accept both `llvm.loop.unroll.full` and `llvm.loop.unroll.enable` metadata on the same loop (PR #182381)

Justin Fargnoli via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 19 14:01:59 PST 2026


https://github.com/justinfargnoli updated https://github.com/llvm/llvm-project/pull/182381

>From 59ee4cff4c4fe85bfa78cf6e3387ca045ff21beb Mon Sep 17 00:00:00 2001
From: Justin Fargnoli <jfargnoli at nvidia.com>
Date: Thu, 19 Feb 2026 20:26:41 +0000
Subject: [PATCH 1/2] [llvm][Verifier] Accept both `llvm.loop.unroll.full` and
 `llvm.loop.unroll.enable` metadata on the same loop

---
 .../loop-metadata-unroll-full-enable.ll       | 26 +++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100644 llvm/test/Verifier/loop-metadata-unroll-full-enable.ll

diff --git a/llvm/test/Verifier/loop-metadata-unroll-full-enable.ll b/llvm/test/Verifier/loop-metadata-unroll-full-enable.ll
new file mode 100644
index 0000000000000..f571d1a1e0910
--- /dev/null
+++ b/llvm/test/Verifier/loop-metadata-unroll-full-enable.ll
@@ -0,0 +1,26 @@
+; RUN: opt < %s -passes=verify -S -o /dev/null
+
+; Test that the verifier accepts loop metadata containing both
+; llvm.loop.unroll.full and llvm.loop.unroll.enable simultaneously.
+
+define void @loop_full_and_enable(ptr nocapture %a) {
+entry:
+  br label %for.body
+
+for.body:
+  %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
+  %ptr = getelementptr inbounds i32, ptr %a, i64 %iv
+  %val = load i32, ptr %ptr, align 4
+  %inc = add nsw i32 %val, 1
+  store i32 %inc, ptr %ptr, align 4
+  %iv.next = add nuw nsw i64 %iv, 1
+  %cmp = icmp eq i64 %iv.next, 32
+  br i1 %cmp, label %exit, label %for.body, !llvm.loop !0
+
+exit:
+  ret void
+}
+
+!0 = distinct !{!0, !1, !2}
+!1 = !{!"llvm.loop.unroll.full"}
+!2 = !{!"llvm.loop.unroll.enable"}

>From 086560d36ce79c6311f1c2d42ed98b06187b0ec9 Mon Sep 17 00:00:00 2001
From: Justin Fargnoli <jfargnoli at nvidia.com>
Date: Thu, 19 Feb 2026 22:01:47 +0000
Subject: [PATCH 2/2] Simplify test

---
 .../Verifier/loop-metadata-unroll-full-enable.ll  | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/llvm/test/Verifier/loop-metadata-unroll-full-enable.ll b/llvm/test/Verifier/loop-metadata-unroll-full-enable.ll
index f571d1a1e0910..2ffdddc0c88fa 100644
--- a/llvm/test/Verifier/loop-metadata-unroll-full-enable.ll
+++ b/llvm/test/Verifier/loop-metadata-unroll-full-enable.ll
@@ -3,19 +3,12 @@
 ; Test that the verifier accepts loop metadata containing both
 ; llvm.loop.unroll.full and llvm.loop.unroll.enable simultaneously.
 
-define void @loop_full_and_enable(ptr nocapture %a) {
+define void @loop_full_and_enable() {
 entry:
-  br label %for.body
+  br label %loop
 
-for.body:
-  %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
-  %ptr = getelementptr inbounds i32, ptr %a, i64 %iv
-  %val = load i32, ptr %ptr, align 4
-  %inc = add nsw i32 %val, 1
-  store i32 %inc, ptr %ptr, align 4
-  %iv.next = add nuw nsw i64 %iv, 1
-  %cmp = icmp eq i64 %iv.next, 32
-  br i1 %cmp, label %exit, label %for.body, !llvm.loop !0
+loop:
+  br i1 true, label %loop, label %exit, !llvm.loop !0
 
 exit:
   ret void



More information about the llvm-commits mailing list