Skip to content

LLVM broke frontends relying on documented NaN behavior for minnum/maxnum #170082

@RalfJung

Description

@RalfJung

#139581 (specifically, 17efa57) introduced a breaking change that affects Rust and possibly other frontends: we were relying on the documented, stable, established property that for minnum/maxnum,

If either operand is a NaN, returns the other non-NaN operand.

Unfortunately, that documentation got changed in #112852, and then in 17efa57 the implementation also got changed so now maxnum(sNaN, x) is simplified to qNaN. As a result of that, the code rustc+LLVM generate now no longer matches what we document in the Rust standard library. (This does not completely fix the implementation though. LLVM is currently implementing a messy mix of old and new semantics, which is being discussed in #138451, Discourse, and some other places. That's not what this issue is about; this issue is about the tangible effects on frontends.)

I consider this a regression introduced by #139581; IMO the problematic commit in that PR should be reverted. Changing the behavior of existing intrinsics used by frontends requires more care. Also, https://llvm.org/docs/LangRef.html#llvm-minimumnum-intrinsic exists for those that want the IEEE754-2019 semantics, so it's not clear to me why the old minnum intrinsic has to change. IIUC, 17efa57 has not made it into any release yet, so there's still a chance of fixing this before it affects Rust users.

Cc @LewisCrawford @nikic @arsenm

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions