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

[Blocked] Use const fn where easily applicable. #262

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

phip1611
Copy link
Contributor

@phip1611 phip1611 commented Mar 10, 2022

Update 2023-12-18

This is still blocked by having these features not in stable.

#![feature(const_float_bits_conv)]
#![feature(const_fn_floating_point_arithmetic)]
#![feature(const_float_classify)]

This commit adds "const fn" where possible without major refactorings. All functions that rely on special LLVM runtime intrinsic (such as SSE) or core::ptr::read_volatile are untouched by this.

Currently, the CI does not pass. I'd like to know if you think this PR is beneficial at all. If so, we/I can work further on it. Currently, many functions can't be ported to be a "const fn" easily because many of them rely on core::ptr::read_volatile during runtime.

This will be breaking because it requires a recent rust nightly. Let me know what you think!

This commit adds "const fn" where possible without major refactorings. All functions that rely on special LLVM runtime intrinsic (such as SSE) or core::ptr::read are untouched by this.
@Amanieu
Copy link
Member

Amanieu commented Mar 21, 2022

I am generally in favor of the PR!

The volatile reads are a bit of a hack. I believe they were used for 2 purposes:

  • To set the appropriate FP status flags (overflow, underflow, etc) in the FP status register. We really shouldn't bother with this since we don't guarantee any particular value for flags.
  • To work around FP precision issues on 32-bit x86 which uses 80-bit float precision internally. This is unfortunately an unavoidable issue on x86 since it has pretty broken FP support.

@phip1611 phip1611 changed the title Use const fn where easily applicable. [Blocked] Use const fn where easily applicable. Dec 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants