[Mlir-commits] [mlir] [mlir][tosa] Avoid introducing int <-> float casts (PR #195882)
Luke Hutton
llvmlistbot at llvm.org
Wed May 6 01:52:40 PDT 2026
================
@@ -941,6 +941,13 @@ struct NonNarrowingCastsOptimization : public OpRewritePattern<tosa::CastOp> {
"legal in TOSA");
}
+ if (innerInputType.getElementType().isInteger() !=
+ outerOutputType.getElementType().isInteger()) {
+ return rewriter.notifyMatchFailure(
+ castOp, "integer to float and float to integer casts are not "
+ "supported to avoid introducing illegal type combinations");
+ }
----------------
lhutton1 wrote:
This seems to block optimization of legitimate cases such as:
```
i8 -> cast -> i16 -> cast -> fp16
```
Looking at the spec, integer inputs have full coverage for casts to floating point types. It's support for bool that was missing in 1.0. I wonder if we can relax this check and apply the above logic only when the input type is bool?
https://github.com/llvm/llvm-project/pull/195882
More information about the Mlir-commits
mailing list