[Mlir-commits] [mlir] add zero check for number of loop ops (PR #144841)
Ayokunle Amodu
llvmlistbot at llvm.org
Wed Jun 18 22:29:10 PDT 2025
https://github.com/ayokunle321 created https://github.com/llvm/llvm-project/pull/144841
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
>From 6cb539e52855bcc50b330318b5903dd1dce309d4 Mon Sep 17 00:00:00 2001
From: Ayokunle Amodu <121697771+ayokunle321 at users.noreply.github.com>
Date: Wed, 18 Jun 2025 23:22:00 -0600
Subject: [PATCH] add zero check for number of loop ops
---
mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp | 2 ++
1 file changed, 2 insertions(+)
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;
More information about the Mlir-commits
mailing list