[Mlir-commits] [mlir] [MLIR] Clarify createOrFold as opportunistic eager folding (PR #160565)

NohHyeon Kwon llvmlistbot at llvm.org
Wed Sep 24 10:16:16 PDT 2025


https://github.com/swote-git created https://github.com/llvm/llvm-project/pull/160565

This PR addresses the documentation aspect of #159844 by clarifying the opportunistic nature of `createOrFold`, as discussed with @joker-eph.

This addresses user confusion about createOrFold behavior compared to canonicalization passes.

>From dfb865732c65f45b5ee513bb58c7adfaffbdb1e9 Mon Sep 17 00:00:00 2001
From: swote <kst7703 at gmail.com>
Date: Thu, 25 Sep 2025 02:12:41 +0900
Subject: [PATCH] [MLIR] Clarify createOrFold as opportunistic eager folding

Add documentation note explaining that createOrFold performs
opportunistic eager folding during IR construction, attempting
optimization only once without iterative refinement.

This addresses user confusion about createOrFold behavior
compared to canonicalization passes.

Addresses #159844
---
 mlir/include/mlir/IR/Builders.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/mlir/include/mlir/IR/Builders.h b/mlir/include/mlir/IR/Builders.h
index ad59ea63a6901..7a137125eb440 100644
--- a/mlir/include/mlir/IR/Builders.h
+++ b/mlir/include/mlir/IR/Builders.h
@@ -513,6 +513,9 @@ class OpBuilder : public Builder {
   /// Create an operation of specific op type at the current insertion point,
   /// and immediately try to fold it. This functions populates 'results' with
   /// the results of the operation.
+  ///
+  /// Note: This performs opportunistic eager folding during IR construction,
+  /// attempting optimization only once without iterative refinement.
   template <typename OpTy, typename... Args>
   void createOrFold(SmallVectorImpl<Value> &results, Location location,
                     Args &&...args) {



More information about the Mlir-commits mailing list