[Mlir-commits] [mlir] [mlir] Fix block merging (PR #102038)
Giuseppe Rossini
llvmlistbot at llvm.org
Mon Aug 5 12:06:48 PDT 2024
giuseros wrote:
Hi @Dinistro , it was actually a small bug (unfortunately I was on holiday, otherwise I could have sorted that without going through the revert process).
@krzysz00 , @Mogball , this is the same PR you already review (so the logic is almost unchanged). What basically changed is the logic to prune a new argument within the block. The original code was
```
Value oldArg = block->getArgument(idx);
Value newArg = block->getArgument(idxToReplacement[idx]);
rewriter.replaceAllUsesWith(oldArg, newArg);
toErase.push_back(idx);
```
Where `idx` is the index of the `oldArgument`. However, such index had to be offset by the number of block arguments that were already there.
So, the above code, becomes:
```
Value oldArg = block->getArgument(numOldArguments + idx);
Value newArg = block->getArgument(numOldArguments + idxToReplacement[idx]);
rewriter.replaceAllUsesWith(oldArg, newArg);
toErase.push_back(numOldArguments + idx);
```
https://github.com/llvm/llvm-project/pull/102038
More information about the Mlir-commits
mailing list