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 report: FSQRT of non-canonical NaN gives valid large floats #84

Open
flaviens opened this issue Apr 17, 2023 · 0 comments
Open

Bug report: FSQRT of non-canonical NaN gives valid large floats #84

flaviens opened this issue Apr 17, 2023 · 0 comments

Comments

@flaviens
Copy link
Contributor

flaviens commented Apr 17, 2023

Hi there!

fsqrt was known to produce some off-by-one errors, and may return 1 on canonical NaN.

This snippet shows that additionally to these known problems, fsqrt.s can return large valid floating-point numbers instead of NaNs, when the input is a non-canonical NaN.
Hence, this is another bug than the reported off-by-one. I do not know at the moment whether the root cause is shared.

  .section ".text.init","ax",@progbits
  .globl _start
  .align 2
_start:

  # Enable the FPU
  li t0, 0x2000
  csrs mstatus, t0
  csrw	fcsr,x0

  la t0, .fdata0
  fld ft0, (t0)

  fsqrt.s ft2, ft0

infinite_loop:
  j infinite_loop

.section ".fdata0","ax",@progbits
  .8byte 0xc5d584907716dd07

Got ft2=0x5b7c271f which corresponds to 7.09747e+16, instead of ft2=0x7fc00000=nan.
Tested with Ariane with cvfpu 0.7.0 (109f9e9ed3adff25464db3aa021cb88119b7bf53).

Thanks!
Flavien

@flaviens flaviens changed the title FSQRT of non-canonical NaN gives valid large floats Bug report: FSQRT of non-canonical NaN gives valid large floats Apr 17, 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

No branches or pull requests

1 participant