[Mlir-commits] [mlir] add zero check for number of loop ops (PR #144841)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Wed Jun 18 22:29:40 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir-affine
Author: Ayokunle Amodu (ayokunle321)
<details>
<summary>Changes</summary>
Related: #<!-- -->139231
This patch fixes a crash in the affine-loop-fusion pass when `getInnermostCommonLoop` is called with an empty list of operations.
The function expects at least one op to analyze, and passing an empty array of ops causes an assertion failure. This change ensures the pass checks for an empty op array before calling `getInnermostCommonLoop`.
@<!-- -->bondhugula @<!-- -->matthias-springer
---
Full diff: https://github.com/llvm/llvm-project/pull/144841.diff
1 Files Affected:
- (modified) mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp (+2)
``````````diff
diff --git a/mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp b/mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp
index 4b4eb9ce37b4c..5c5d041ed6bdc 100644
--- a/mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp
+++ b/mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp
@@ -997,6 +997,8 @@ struct GreedyFusion {
if (producerConsumerMemrefs.count(
cast<AffineWriteOpInterface>(op).getMemRef()))
dstMemrefOps.push_back(op);
+ if (dstMemrefOps.size() == 0)
+ continue;
unsigned dstLoopDepthTest =
getInnermostCommonLoopDepth(dstMemrefOps) - numSurroundingLoops;
``````````
</details>
https://github.com/llvm/llvm-project/pull/144841
More information about the Mlir-commits
mailing list