[Mlir-commits] [mlir] [mlir][affine] Add unroll-factor description for loop unroll pass (PR #172791)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Wed Dec 17 21:39:40 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir-scf

@llvm/pr-subscribers-mlir-affine

Author: lonely eagle (linuxlonelyeagle)

<details>
<summary>Changes</summary>

Add the description that unroll-factor equals -1 for loop unroll pass.

---
Full diff: https://github.com/llvm/llvm-project/pull/172791.diff


2 Files Affected:

- (modified) mlir/include/mlir/Dialect/Affine/Passes.td (+2-1) 
- (modified) mlir/test/lib/Dialect/SCF/TestLoopUnrolling.cpp (+5-3) 


``````````diff
diff --git a/mlir/include/mlir/Dialect/Affine/Passes.td b/mlir/include/mlir/Dialect/Affine/Passes.td
index bb6b41c0bba35..1ad5344121d4e 100644
--- a/mlir/include/mlir/Dialect/Affine/Passes.td
+++ b/mlir/include/mlir/Dialect/Affine/Passes.td
@@ -204,7 +204,8 @@ def AffineLoopUnroll : InterfacePass<"affine-loop-unroll", "FunctionOpInterface"
   let constructor = "mlir::affine::createLoopUnrollPass()";
   let options = [
     Option<"unrollFactor", "unroll-factor", "int64_t", /*default=*/"4",
-           "Use this unroll factor for all loops being unrolled">,
+           "Use this unroll factor for all loops being unrolled, "
+           "set it to -1, and it will fully unroll.">,
     Option<"unrollUpToFactor", "unroll-up-to-factor", "bool",
            /*default=*/"false", "Allow unrolling up to the factor specified">,
     Option<"numRepetitions", "unroll-num-reps", "unsigned", /*default=*/"1",
diff --git a/mlir/test/lib/Dialect/SCF/TestLoopUnrolling.cpp b/mlir/test/lib/Dialect/SCF/TestLoopUnrolling.cpp
index 2470380682318..e2d6996e435bb 100644
--- a/mlir/test/lib/Dialect/SCF/TestLoopUnrolling.cpp
+++ b/mlir/test/lib/Dialect/SCF/TestLoopUnrolling.cpp
@@ -76,9 +76,11 @@ struct TestLoopUnrollingPass
         (void)loopUnrollByFactor(loop, unrollFactor, annotateFn);
     }
   }
-  Option<int64_t> unrollFactor{*this, "unroll-factor",
-                               llvm::cl::desc("Loop unroll factor."),
-                               llvm::cl::init(1)};
+  Option<int64_t> unrollFactor{
+      *this, "unroll-factor",
+      llvm::cl::desc(
+          "Loop unroll factor, set it to -1, and it will fully unroll."),
+      llvm::cl::init(1)};
   Option<bool> annotateLoop{*this, "annotate",
                             llvm::cl::desc("Annotate unrolled iterations."),
                             llvm::cl::init(false)};

``````````

</details>


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


More information about the Mlir-commits mailing list