Tracking issue: 32bit x86 targets lose float NaN payload in return values #115567
Open
Description
opened on Sep 5, 2023
On x86 (32bit) targets, returning a floating-point number from a "C" ABI function by-value can change the bits of their NaN payloads. (Specifically, the quiet bit gets set.) This is caused by using x87 registers to pass return values, as mandated by the ABI for this target.
This is a known and long-standing problem, and very hard to fix. The purpose of this issue mostly is to document its existence and to give it a URL that can be referenced.
A proper fix would require patching LLVM to use different code to load float return values into an x87 register -- specifically, it has to be done in a way that NaN payloads are fully preserved.
Related issues:
- x86-32: floating-point return values undergo implicit format conversion llvm/llvm-project#66803: the same bug on the LLVM side.
- Tracking issue: 32bit x86 targets without SSE2 have unsound floating point behavior #114479: that's a different problem, also affecting x86-32 but concerning the actual FP computations, not the NaN bits of return values.
Prior issues:
Activity