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

[BUG] Incorrect Accumulation of ‘OF’ Flag in fflags After Executing fsqrt.d on Infinity #111

Open
youzi27 opened this issue Apr 22, 2024 · 2 comments

Comments

@youzi27
Copy link

youzi27 commented Apr 22, 2024

Bug Description

When executing the fsqrt.d instruction on a double-precision floating-point value representing positive infinity (0x7ff0000000000000), the Overflow (OF) flag in the fflags register is erroneously set. According to the IEEE 754 standard and the RISC-V specification, the fsqrt.d operation should not lead to an overflow situation when the input is infinity. This also results in inconsistency with Spike's output

Expected Behavior:
The OF flag in the fflags register should remain clear (i.e., not set) after performing a square root operation on an infinite value, as the result is well-defined and should be positive infinity.

Actual Behavior:
The OF flag is set in the fflags register, indicating an overflow, which contradicts the expected behavior defined by the IEEE 754 standard and RISC-V floating-point operation guidelines.

Steps to Reproduce:

  1. Load a double-precision floating-point register with the value 0x7ff0000000000000 (positive infinity).
  2. Execute the fsqrt.d instruction on this register.
  3. Check the fflags register; observe that the OF flag is incorrectly set.

EDIT: A PR has been submitted pulp-platform/fpu_div_sqrt_mvp#25

EDIT: And See: openhwgroup/cva6#2058

@pascalgouedo
Copy link

pascalgouedo commented Sep 6, 2024

Same answer than #110

@youzi27
Copy link
Author

youzi27 commented Sep 6, 2024

Hi @pascalgouedo,

Thank you very much for your detailed explanation.

The bug occurs in the commit version of cvfpu: 79e4531 (v0.8.1), and as you mentioned, I noticed that this version has not yet included "THMULTI."

Additionally, the issue was raised in April, and from checking the commit records, it seems that "THMULTI" was only introduced to cvfpu in May.

Furthermore, I have reviewed the bugs that have been reported previously and did not see this mentioned, which is why I raised an issue. I will verify whether adding "THMULTI" resolves the bug.

Thank you very much.

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