[Mlir-commits] [mlir] [mlir][SCF]-Fix loop coalescing with iteration arguements (PR #105488)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Wed Aug 21 14:48:12 PDT 2024
================
@@ -864,6 +864,18 @@ LogicalResult mlir::coalesceLoops(RewriterBase &rewriter,
Operation *innerTerminator = innerLoop.getBody()->getTerminator();
auto yieldedVals = llvm::to_vector(innerTerminator->getOperands());
+ assert(llvm::equal(outerLoop.getRegionIterArgs(), innerLoop.getInitArgs()));
+ for (Value &yieldedVal : yieldedVals) {
+ // The yielded value may be an iteration argument of the inner loop
+ // which is about to be inlined.
+ auto iter = llvm::find(innerLoop.getRegionIterArgs(), yieldedVal);
+ if (iter != innerLoop.getRegionIterArgs().end()) {
+ unsigned iterArgIndex = iter - innerLoop.getRegionIterArgs().begin();
+ // `outerLoop` iter args identical to the `innerLoop` init args.
----------------
MaheshRavishankar wrote:
Basically, I think instead of
```
yieldedVal = outerLoop.getRegionIterArgs()[..]
```
it should be
```
yieldedVal = innerLoop.getInitArgs()[...]
```
Sorry, the IR format and method names are confusing...
https://github.com/llvm/llvm-project/pull/105488
More information about the Mlir-commits
mailing list