[Mlir-commits] [mlir] [mlir][tosa][tosa-to-linalg] tosa.cast: fix answer mismatch to cast f64/f32 max value to i64/i32 (PR #130116)

Eric Kunze llvmlistbot at llvm.org
Wed Mar 12 10:53:20 PDT 2025


https://github.com/eric-k256 requested changes to this pull request.

I don't think this should go in. It is different than what the TOSA spec behavior is, and there isn't anything in the code explaining why a value greater than the maximum representable should be output as the lowest output value.

You could propose a change to the TOSA spec, but adding an attribute to choose behavior means that both paths would need to be tested. I don't expect this to be an issue with real world uses, as relying on undefined behavior is dangerous. 

If it was important to match the dialect behavior, you could check for overflow before the CAST and then do a SELECT for the appropriate value after the CAST. That way you could get the framework behavior and TOSA doesn't need to change.

https://github.com/llvm/llvm-project/pull/130116


More information about the Mlir-commits mailing list