[flang-commits] [flang] [flang] Respect math flags during conversions (PR #214311)

Steve Scalpone via flang-commits flang-commits at lists.llvm.org
Thu Sep 17 23:52:50 PDT 2026


sscalpone wrote:

@jon-gibney Fujitsu test 0291/0291_0008.f gets poisoned.  Inf loop on aarch64.  Seg fault on x86.

On aarch64, there's no additional overhead.  In LLVM IR, both standard floating-point-to-signed-integer cast (fptosi) and the explicit saturating intrinsic (@llvm.fptosi.sat) lower to the exact same FCVTZS assembly instruction on AArch64 for 32-bit and 64-bit integer types (sez gemini).

Because the ARM AArch64 hardware specification requires FCVTZS to saturate out-of-bounds inputs (and map NaNs to zero) directly at the instruction level, the architecture clamps values properly by default. As a result, switching between fptosi and @llvm.fptosi.sat incurs zero instruction overhead on AArch64.

The check on x86_64 is expensive.

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


More information about the flang-commits mailing list