| Issue |
243906
|
| Summary |
[mlir][Linalg] convert-arith-to-apfloat invalidates named linalg.matmul regions
|
| Labels |
mlir
|
| Assignees |
|
| Reporter |
lin334141-cell
|
## Summary
`convert-arith-to-apfloat` rewrites `arith.mulf` and `arith.addf` inside a named `linalg.matmul` region into APFloat runtime calls, leaving the operation unverifiable:
```
error: expected add/mul op in the body
```
This is another pass-specific manifestation of the underlying named-region issue discussed in #217967, but it involves a different conversion implementation.
## Minimal Reproducer
```mlir
module {
func.func @f(%a: tensor<2x3xf32>, %b: tensor<3x2xf32>, %c: tensor<2x2xf32>) -> tensor<2x2xf32> {
%0 = linalg.matmul ins(%a, %b : tensor<2x3xf32>, tensor<3x2xf32>) outs(%c : tensor<2x2xf32>) -> tensor<2x2xf32>
return %0 : tensor<2x2xf32>
}
}
```
**Commands:**
```bash
mlir-opt minimal.mlir --verify-each -o /dev/null
# Success
mlir-opt minimal.mlir --convert-arith-to-apfloat
# error: expected add/mul op in the body
```
## Expected Behavior
The conversion should preserve the validity of the named `linalg.matmul` operation, or avoid rewriting its region until the named operation has been lowered.
## Actual Behavior
`BinaryArithOpToAPFloatConversion` replaces the region's multiplication and addition with calls to `_mlir_apfloat_multiply` and `_mlir_apfloat_add`, together with operand and result conversions.
This breaks the named Linalg operation's required multiplication/addition structure, causing verification to fail.
Lowering the named Linalg operation to loops before applying the APFloat conversion avoids the failure.
## Tested Versions
Reproduced on:
- LLVM main `c1856996d677c1b3578752e6781d0df46617fd68` (November 6, 2026)
- LLVM 24.0.0 development nightly associated with `cecb42f82e628dbdeeeee586086c2006844716aa` (November 16, 2026)
During a 24-hour MLIR fuzzing campaign, 47 generated programs triggered this APFloat verifier failure. Of these, 45 also triggered the analogous `convert-arith-to-llvm` failure.
## Related Issue
#217967 reports the same underlying named Linalg region constraint violation through `convert-arith-to-llvm`.
This report documents a second affected pass, `convert-arith-to-apfloat`, implemented in `mlir/lib/Conversion/ArithAndMathToAPFloat/ArithToAPFloat.cpp`.
Both cases share the same verifier failure and underlying root cause. The APFloat path is reported separately to provide a concrete reproducer and track this additional affected conversion.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs