Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LLVM (thus, Rust) floating point support support is incomplete #10186

Closed
thestinger opened this issue Oct 31, 2013 · 11 comments
Closed

LLVM (thus, Rust) floating point support support is incomplete #10186

thestinger opened this issue Oct 31, 2013 · 11 comments
Labels
A-floating-point Area: Floating point numbers and arithmetic A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@thestinger
Copy link
Contributor

  • signalling NaN results in undefined behaviour
  • floating point environment (rounding mode, exceptions) is not supported

This is not going to be easy to fix since the only sane fix is to improve LLVM.

@pnkfelix
Copy link
Member

cc @nikomatsakis since i think this is relevant to a point of discussion from last night's triage meeting.

@steveklabnik
Copy link
Member

triage bump: I don't follow LLVM development closely enough to know if anything has changed here, but it's true, if they're deficient, it's going to be hard for us.

@eefriedman
Copy link
Contributor

eefriedman commented Jun 27, 2015

This is https://bugs.llvm.org//show_bug.cgi?id=8100 on the LLVM side; it's a longstanding issue.

@steveklabnik
Copy link
Member

Triage: LLVM bug is still open.

@Mark-Simulacrum Mark-Simulacrum added C-feature-request Category: A feature request, i.e: not implemented / a PR. and removed C-enhancement Category: An issue proposing an enhancement or a PR with one. labels Jul 19, 2017
@Mark-Simulacrum Mark-Simulacrum added C-bug Category: This is a bug. and removed C-feature-request Category: A feature request, i.e: not implemented / a PR. I-wrong labels Jul 28, 2017
@varkor
Copy link
Member

varkor commented Dec 22, 2017

Since https://reviews.llvm.org/D27028 (late January 2017), LLVM has had experimental intrinsics for floating-point environment support (see llvm.experimental.constrained.*). It's probably better to wait until they're stabilised before implementing the corresponding functionality in Rust?

@bstrie
Copy link
Contributor

bstrie commented Oct 16, 2018

@varkor , is there an LLVM tracking issue for when (or if) those might be stabilized? cc #55107

@varkor
Copy link
Member

varkor commented Oct 16, 2018

@bstrie: I've not found one, unfortunately 😕The process seems to be ad hoc. From what I could tell, the intrinsics should be correct, but not necessarily efficient.

@hanna-kruppe
Copy link
Contributor

The intrinsics exist in IR but last I heard backend support was incomplete, at least in the sense that dependencies between instructions that affect or are affected by the floating point environment are not respected in MachineIR.

@RalfJung
Copy link
Member

signalling NaN results in undefined behaviour

Is that true? I seem to recall that LLVM just doesn't care about signalling vs not-signalling, and so does most hardware. So for those platforms, they are not UB, they are just not implemented.

@Tastaturtaste
Copy link

@bstrie: I've not found one, unfortunately 😕The process seems to be ad hoc. From what I could tell, the intrinsics should be correct, but not necessarily efficient.

Will rust adopt the correct or the efficient semantics for fp math? Is there already some way to use what intrinsics llvm does have in rust?

@Noratrieb Noratrieb added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Apr 5, 2023
@RalfJung
Copy link
Member

RalfJung commented Aug 4, 2023

  • signalling NaN results in undefined behaviour

That is not true. Signalling NaNs are not behaving entirely in line with IEEE, but they do not cause UB. #73328 is tracking the exact documentation of that.

  • floating point environment (rounding mode, exceptions) is not supported

That is true, but currently "working as intended". So this is not considered "incomplete". If someone wants to track support for custom FP environments, please open a feature request. This would require an RFC, and very careful design since we do not want to impede out ability to optimize regular floating-point operations assuming the default environment.

@RalfJung RalfJung closed this as completed Aug 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-floating-point Area: Floating point numbers and arithmetic A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

13 participants