[Mlir-commits] [mlir] [mlir][async] Clamp per-axis trip counts in async-parallel-for (PR #225370)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Tue Sep 22 04:21:06 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir
Author: Shoryamishra61
<details>
<summary>Changes</summary>
### Problem
`AsyncParallelFor` computes each dimension's trip count using signed ceiling division and directly multiplies those values to form the flattened iteration count.
For an empty dimension with a positive step, the raw result can be negative. If multiple dimensions are empty, multiplying an even number of negative trip counts can produce a positive flattened count, causing work to be dispatched for an `scf.parallel` operation whose semantic iteration space is empty.
### Fix
Normalize each per-dimension trip count to a non-negative iteration cardinality before computing the flattened trip count:
```cpp
Value rawTripCount = b.createOrFold<arith::CeilDivSIOp>(range, step);
tripCounts[i] = b.createOrFold<arith::MaxSIOp>(rawTripCount, c0);
```
This ensures any empty dimension contributes zero to the Cartesian-product iteration space while preserving positive trip counts for non-empty dimensions.
### Tests
Add regression coverage to `mlir/test/Dialect/Async/async-parallel-for-async-dispatch.mlir`:
- `@<!-- -->empty_2d_dynamic`: Multidimensional empty iteration domain with dynamic bounds ensuring each dimension clamps to zero and takes the no-op branch.
- `@<!-- -->empty_2d_static`: Constant bounds verifying compile-time folding of empty dimensions to a no-op branch.
Fixes #<!-- -->225254.
---
Full diff: https://github.com/llvm/llvm-project/pull/225370.diff
2 Files Affected:
- (modified) mlir/lib/Dialect/Async/Transforms/AsyncParallelFor.cpp (+7-3)
- (modified) mlir/test/Dialect/Async/async-parallel-for-async-dispatch.mlir (+40)
``````````diff
The server is unavailable at this time. Please wait a few minutes before you try again.
``````````
</details>
https://github.com/llvm/llvm-project/pull/225370
More information about the Mlir-commits
mailing list