[all-commits] [llvm/llvm-project] 6e714c: [MLIR][SCF] Fix upliftWhileToForLoop post-loop IV ...
Nick Riasanovsky via All-commits
all-commits at lists.llvm.org
Tue Sep 22 14:58:35 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 6e714c8d91116794cb699cdf80c26afe9cda3ef3
https://github.com/llvm/llvm-project/commit/6e714c8d91116794cb699cdf80c26afe9cda3ef3
Author: Nick Riasanovsky <njriasan at meta.com>
Date: 2026-09-22 (Tue, 22 Sep 2026)
Changed paths:
M mlir/lib/Dialect/SCF/Transforms/UpliftWhileToFor.cpp
M mlir/test/Dialect/SCF/uplift-while.mlir
Log Message:
-----------
[MLIR][SCF] Fix upliftWhileToForLoop post-loop IV value (#225476)
scf::upliftWhileToForLoop transforms a while loop that can be expressed
as a for loop into that for loop. For example in pseudocode:
```
var = init_val
while var < bound:
...
var += step
```
into
```
for (var=lb; var < bound; var += step) {
...
}
```
In this process the post-loop induction value is reconstructed as `lb +
(tripCount - 1) * step`. This is incorrect as there is a off by 1 error.
Here we reconstruct lb + max(ceilDiv(ub-lb, step), 0) * step instead:
drop the spurious -1 and clamp the trip count at zero for loops that
never execute. Adds a zero-trip regression test that folds to lb.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list