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

[question] Protected against LLVM reordreing bug? #60

Closed
Chris00 opened this issue Dec 19, 2021 · 1 comment
Closed

[question] Protected against LLVM reordreing bug? #60

Chris00 opened this issue Dec 19, 2021 · 1 comment

Comments

@Chris00
Copy link
Contributor

Chris00 commented Dec 19, 2021

I saw that LLVM can reorder rounding-mode-sensitive float operations outside rounding mode changes in SSE so I was wondering whether Inari is affected by this. While I am at it, I would like to make sure that I understood well the code (my ASM is very limited) and that there is no rounding that can adversely affect the result when stored from extended precision into memory. (I want to use your library for computer assisted proofs and I'd like to be reassured that it is 100% reliable. 😀)

@unageek
Copy link
Owner

unageek commented Dec 20, 2021

The add_ru function, for example, does the following:

  1. Save the current value of the MXCSR register to the stack.
  2. Set the value of the MXCSR register to 24448 or 0x5F80, which tells FP operations to round the result toward +∞, while suppressing any FP exceptions.
  3. Perform FP addition.
  4. Restore the saved value of the MXCSR register.

The above operations are embedded in a single inline asm, which is immune to optimizations.

@unageek unageek closed this as completed Dec 31, 2021
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

No branches or pull requests

2 participants