[Mlir-commits] [mlir] [mlir] Remove loop peeling explicit C'tor (PR #175419)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Sun Jan 11 01:06:08 PST 2026


llvmbot wrote:


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

@llvm/pr-subscribers-mlir

Author: ofri frishman (ofri-frishman)

<details>
<summary>Changes</summary>

The SCF dialect loop peeling pass has an explicit C'tor. This creates an inconvenience to use non default pass options, since they can only be passed as a string after the pass creation. After removing the explicit C'tor, the code auto generation creates 2 C'tors, which one of them can directly receive pass options struct in case non default values are required.
The explicit C'tor does not match auto generated C'tor convention, so this change requires any uses of the pass in downstream projects to update to use the auto generated C'tor.

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


3 Files Affected:

- (modified) mlir/include/mlir/Dialect/SCF/Transforms/Passes.h (-4) 
- (modified) mlir/include/mlir/Dialect/SCF/Transforms/Passes.td (-1) 
- (modified) mlir/lib/Dialect/SCF/Transforms/LoopSpecialization.cpp (+2-4) 


``````````diff
diff --git a/mlir/include/mlir/Dialect/SCF/Transforms/Passes.h b/mlir/include/mlir/Dialect/SCF/Transforms/Passes.h
index 54b0118507184..e5794dbfeabae 100644
--- a/mlir/include/mlir/Dialect/SCF/Transforms/Passes.h
+++ b/mlir/include/mlir/Dialect/SCF/Transforms/Passes.h
@@ -24,10 +24,6 @@ namespace mlir {
 /// vectorization.
 std::unique_ptr<Pass> createForLoopSpecializationPass();
 
-/// Creates a pass that peels for loops at their upper bounds for
-/// better vectorization.
-std::unique_ptr<Pass> createForLoopPeelingPass();
-
 /// Creates a pass that canonicalizes affine.min and affine.max operations
 /// inside of scf.for loops with known lower and upper bounds.
 std::unique_ptr<Pass> createSCFForLoopCanonicalizationPass();
diff --git a/mlir/include/mlir/Dialect/SCF/Transforms/Passes.td b/mlir/include/mlir/Dialect/SCF/Transforms/Passes.td
index 3ac651f53880c..44e523fdfb8fe 100644
--- a/mlir/include/mlir/Dialect/SCF/Transforms/Passes.td
+++ b/mlir/include/mlir/Dialect/SCF/Transforms/Passes.td
@@ -23,7 +23,6 @@ def SCFForLoopCanonicalization
 
 def SCFForLoopPeeling : Pass<"scf-for-loop-peeling"> {
   let summary = "Peel `for` loops at their upper bounds.";
-  let constructor = "mlir::createForLoopPeelingPass()";
   let options = [
     Option<"peelFront", "peel-front", "bool",
            /*default=*/"false",
diff --git a/mlir/lib/Dialect/SCF/Transforms/LoopSpecialization.cpp b/mlir/lib/Dialect/SCF/Transforms/LoopSpecialization.cpp
index c7588b433dee1..cff01d1de17e8 100644
--- a/mlir/lib/Dialect/SCF/Transforms/LoopSpecialization.cpp
+++ b/mlir/lib/Dialect/SCF/Transforms/LoopSpecialization.cpp
@@ -337,6 +337,8 @@ struct ForLoopSpecialization
 };
 
 struct ForLoopPeeling : public impl::SCFForLoopPeelingBase<ForLoopPeeling> {
+  using impl::SCFForLoopPeelingBase<ForLoopPeeling>::SCFForLoopPeelingBase;
+
   void runOnOperation() override {
     auto *parentOp = getOperation();
     MLIRContext *ctx = parentOp->getContext();
@@ -360,7 +362,3 @@ std::unique_ptr<Pass> mlir::createParallelLoopSpecializationPass() {
 std::unique_ptr<Pass> mlir::createForLoopSpecializationPass() {
   return std::make_unique<ForLoopSpecialization>();
 }
-
-std::unique_ptr<Pass> mlir::createForLoopPeelingPass() {
-  return std::make_unique<ForLoopPeeling>();
-}

``````````

</details>


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


More information about the Mlir-commits mailing list