llvm-project
b9bf4463 - [mlir][Linalg] Fix output block arg remapping in DecomposeLinalgOp (#238168)

Commit
4 hours ago
[mlir][Linalg] Fix output block arg remapping in DecomposeLinalgOp (#238168) `DecomposeLinalgOp` splits a `linalg.generic` into a peeled op for the first statement and a residual op for the rest. The residual op takes the results of the peeled op as extra inputs, placed between the original inputs and outputs, but uses of the original block arguments are remapped by position. An output block argument used in the residual body therefore ends up on one of the extra inputs. For an f32 body like `%0 = arith.mulf %in, %in` followed by `%1 = arith.addf %0, %out`, the residual op computes `addf(%0, %0)` instead of `addf(%0, %out)`. The IR verifies and silently computes wrong values. When the types differ the IR becomes invalid instead, e.g. the fold assertion in #237535. The existing `destination_passing_style` test encoded the same wrong mapping: its residual `mulf` read the first output instead of the second one. Shift the output block argument indices by the number of extra inputs, correct the `destination_passing_style` checks, and add a regression test. Fixes #237535
Author
Parents
Loading