Skip to content

Tracking issue: 32bit x86 targets lose float NaN payload in return values #115567

Description

@RalfJung

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 requires a format conversion, and that conversion quiets NaNs. For targets that require SSE2, we have patched the "Rust" ABI to avoid this problem; x86-32 targets where SSE2 is optional have the same problem for "Rust" functions as well.

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. It would be lovely if we could find someone who both cares enough about x86-32 to make sure it correctly implements the Rust semantics and who has the expertise to write the LLVM patch this requires. :)

Related issues:

Prior issues:

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ABIArea: Concerning the application binary interface (ABI)A-floating-pointArea: Floating point numbers and arithmeticC-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCI-miscompileIssue: Correct Rust code lowers to incorrect machine codeO-x86_32Target: x86 processors, 32 bit (like i686-*) (also known as IA-32, i386, i586, i686)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions