Skip to content

Conversation

linuxlonelyeagle
Copy link
Member

@linuxlonelyeagle linuxlonelyeagle commented Sep 17, 2025

When loops is empty, avoid executing yieldTiledValuesFn and Add a test which all tile sizes are set to zero.

@llvmbot
Copy link
Member

llvmbot commented Sep 17, 2025

@llvm/pr-subscribers-mlir-linalg

@llvm/pr-subscribers-mlir-scf

Author: lonely eagle (linuxlonelyeagle)

Changes

When loops is empty, avoid executing yieldTiledValuesFn.


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

1 Files Affected:

  • (modified) mlir/lib/Dialect/SCF/Transforms/TileUsingInterface.cpp (+2-3)
diff --git a/mlir/lib/Dialect/SCF/Transforms/TileUsingInterface.cpp b/mlir/lib/Dialect/SCF/Transforms/TileUsingInterface.cpp
index 834c02126fa53..f24310ecd7beb 100644
--- a/mlir/lib/Dialect/SCF/Transforms/TileUsingInterface.cpp
+++ b/mlir/lib/Dialect/SCF/Transforms/TileUsingInterface.cpp
@@ -455,6 +455,8 @@ static LogicalResult generateLoopNestUsingForOp(
     rewriter.setInsertionPointToEnd(loop.getBody());
     destinationTensors = loop.getRegionIterArgs();
   }
+  if (loops.empty())
+    return success();
 
   SmallVector<Value> tiledResults;
   SmallVector<SmallVector<OpFoldResult>> resultOffsets, resultSizes;
@@ -463,9 +465,6 @@ static LogicalResult generateLoopNestUsingForOp(
     return rewriter.notifyMatchFailure(
         loc, "failed to generate inner tile loop body");
   }
-  if (loops.empty())
-    return success();
-
   assert(tiledResults.size() == destinationTensors.size() &&
          "Number of results of body should be equal to number of iter args");
 

@llvmbot
Copy link
Member

llvmbot commented Sep 17, 2025

@llvm/pr-subscribers-mlir

Author: lonely eagle (linuxlonelyeagle)

Changes

When loops is empty, avoid executing yieldTiledValuesFn.


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

1 Files Affected:

  • (modified) mlir/lib/Dialect/SCF/Transforms/TileUsingInterface.cpp (+2-3)
diff --git a/mlir/lib/Dialect/SCF/Transforms/TileUsingInterface.cpp b/mlir/lib/Dialect/SCF/Transforms/TileUsingInterface.cpp
index 834c02126fa53..f24310ecd7beb 100644
--- a/mlir/lib/Dialect/SCF/Transforms/TileUsingInterface.cpp
+++ b/mlir/lib/Dialect/SCF/Transforms/TileUsingInterface.cpp
@@ -455,6 +455,8 @@ static LogicalResult generateLoopNestUsingForOp(
     rewriter.setInsertionPointToEnd(loop.getBody());
     destinationTensors = loop.getRegionIterArgs();
   }
+  if (loops.empty())
+    return success();
 
   SmallVector<Value> tiledResults;
   SmallVector<SmallVector<OpFoldResult>> resultOffsets, resultSizes;
@@ -463,9 +465,6 @@ static LogicalResult generateLoopNestUsingForOp(
     return rewriter.notifyMatchFailure(
         loc, "failed to generate inner tile loop body");
   }
-  if (loops.empty())
-    return success();
-
   assert(tiledResults.size() == destinationTensors.size() &&
          "Number of results of body should be equal to number of iter args");
 

Copy link
Contributor

@MaheshRavishankar MaheshRavishankar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! As far as I remember the logic though, since we previously check that the tile sizes are not all 0 (which leads to no loops), this shouldnt happen here. But no harm.

Could you add a test for this?

@linuxlonelyeagle
Copy link
Member Author

@MaheshRavishankar ping for review.Thank you.

@linuxlonelyeagle
Copy link
Member Author

@MaheshRavishankar Thank you. I remember you answered my question a year or two ago.

@linuxlonelyeagle linuxlonelyeagle merged commit a25eda2 into llvm:main Sep 22, 2025
10 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Sep 22, 2025

LLVM Buildbot has detected a new failure on builder ppc64le-mlir-rhel-clang running on ppc64le-mlir-rhel-test while building mlir at step 6 "test-build-check-mlir-build-only-check-mlir".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/129/builds/30041

Here is the relevant piece of the build log for the reference
Step 6 (test-build-check-mlir-build-only-check-mlir) failure: 1200 seconds without output running [b'ninja', b'check-mlir'], attempting to kill
...
PASS: MLIR-Unit :: IR/./MLIRIRTests/100/129 (3496 of 3507)
PASS: MLIR-Unit :: IR/./MLIRIRTests/0/129 (3497 of 3507)
PASS: MLIR-Unit :: IR/./MLIRIRTests/39/129 (3498 of 3507)
PASS: MLIR-Unit :: IR/./MLIRIRTests/38/129 (3499 of 3507)
PASS: MLIR-Unit :: Interfaces/./MLIRInterfacesTests/11/22 (3500 of 3507)
PASS: MLIR-Unit :: Interfaces/./MLIRInterfacesTests/13/22 (3501 of 3507)
PASS: MLIR-Unit :: Interfaces/./MLIRInterfacesTests/12/22 (3502 of 3507)
PASS: MLIR-Unit :: Pass/./MLIRPassTests/10/13 (3503 of 3507)
PASS: MLIR :: mlir-tblgen/llvm-intrinsics.td (3504 of 3507)
PASS: MLIR :: mlir-reduce/dce-test.mlir (3505 of 3507)
command timed out: 1200 seconds without output running [b'ninja', b'check-mlir'], attempting to kill
process killed by signal 9
program finished with exit code -1
elapsedTime=1906.447722

YixingZhang007 pushed a commit to YixingZhang007/llvm-project that referenced this pull request Sep 27, 2025
…C) (llvm#159394)

When loops is empty, avoid executing yieldTiledValuesFn and Add a test
which all tile sizes are set to zero.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants