[Mlir-commits] [mlir] [mlir] Expose linearize/delinearize lowering transforms (PR #144156)

Han-Chung Wang llvmlistbot at llvm.org
Tue Jun 17 10:27:42 PDT 2025


================
@@ -32,6 +32,20 @@ enum class BoundType;
 
 namespace affine {
 class AffineApplyOp;
+class AffineDelinearizeIndexOp;
+class AffineLinearizeIndexOp;
+
+/// Lowers `affine.delinearize_index` into a sequence of division and remainder
+/// operations.
+LogicalResult lowerAffineDelinearizeIndexOp(RewriterBase &rewriter,
+                                            AffineDelinearizeIndexOp op);
+
+/// Lowers `affine.linearize_index` into a sequence of multiplications and
+/// additions. Make a best effort to sort the input indices so that
+/// the most loop-invariant terms are at the left of the additions
+/// to enable loop-invariant code motion.
+LogicalResult lowerAffineLinearizeIndexOp(RewriterBase &rewriter,
+                                          AffineLinearizeIndexOp op);
----------------
hanhanW wrote:

I don't follow why we return a LogicalResult for these methods. It seems that it should always succeed. Should they just return `void`, or `Value` and `SmallVector<Value>` for further transformation?

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


More information about the Mlir-commits mailing list