[Mlir-commits] [mlir] [mlir][emitc] Arith to EmitC: handle floating-point<->integer conversions (PR #87614)

Simon Camphausen llvmlistbot at llvm.org
Tue Apr 16 00:50:28 PDT 2024


simon-camp wrote:




> Integer to floating-point conversions can be achieved with C-style casts. However, for floating-point to integer conversions, we must ensure that the rounding mode downstream is actually rounding to zero to preserve the Arith semantics. We add an option, `float-to-int-truncates`, to be set when the downstream rounding mode is guaranteed to be truncation. Otherwise, this conversion remains unsupported for the time being.

Do you have links to documentation on this? As far as I understand implicit conversions and casts ignore the current rounding mode for floating point to integer casts:
Rounding Mode [C](https://en.cppreference.com/w/c/numeric/fenv/FE_round) / [C++](https://en.cppreference.com/w/cpp/numeric/fenv/FE_round):
> The current rounding mode does NOT affect the following:
>
>floating-point to integer implicit conversion and casts (always towards zero)
> ...

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


More information about the Mlir-commits mailing list