[Mlir-commits] [mlir] [mlir][OpenACC] Fix tile clause element bounds for descending loops (PR #227185)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon Sep 28 20:47:14 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir-openacc
@llvm/pr-subscribers-openacc
Author: Vijay Kandiah (VijayKandiah)
<details>
<summary>Changes</summary>
acc.loops could have negative steps, but ACCLoopTiling computed each element loop's bound assuming an ascending one. Both halves of that computation were wrong for a descending dimension: the inclusive edge subtracted one instead of adding one, and the bound was clamped with min instead of max.
For `DO j = n, floor, -1` under `tile(32)`, the last tile's bound came out as `min(floor, j - 33)`, which selects `j - 33` whenever it falls below the floor. The element loop then ran past the end of the iteration space, reading and writing outside the array.
With this change, we pick the clamp and the inclusive edge from the step's direction. When the sign is only known at runtime, we compute both and select on it.
The tiling tests had no coverage of negative steps or of inclusive upper bounds. This patch adds four new tests: descending, descending with an inclusive bound, ascending with an inclusive bound, and a runtime-signed step.
---
Full diff: https://github.com/llvm/llvm-project/pull/227185.diff
3 Files Affected:
- (modified) mlir/lib/Dialect/OpenACC/Transforms/ACCLoopTiling.cpp (+4)
- (modified) mlir/lib/Dialect/OpenACC/Utils/OpenACCUtilsTiling.cpp (+38-9)
- (modified) mlir/test/Dialect/OpenACC/acc-loop-tiling.mlir (+88)
``````````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/227185
More information about the Mlir-commits
mailing list