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

fmadd / fmsub error when adding with zero #158

Closed
helderdaniel opened this issue May 18, 2022 · 1 comment
Closed

fmadd / fmsub error when adding with zero #158

helderdaniel opened this issue May 18, 2022 · 1 comment

Comments

@helderdaniel
Copy link

helderdaniel commented May 18, 2022

Hi,

when trying to use fmadd/fmsub (fnmadd/fnmsub) to add the product with a register that holds floating point zero, the result is always zero:

.data
A: .float 1.0, 2.0, 0.0

.text
la t0, A
flw fa1, 0(t0)
flw fa2, 4(t0)
flw fa3, 8(t0)
fmadd.s fa0, fa1, fa2, fa3 #fa0 = should hold 2.0 but holds 0.0

if fa3 has a value different than zero, it performs the operation correctly:

.data
A: .float 1.0, 2.0, 3.0
(...)
fmadd.s fa0, fa1, fa2, fa3 #fa0 = holds 5.0 as it should

It is not a problem of flw.
Loading zero to fa3 with:

fcvt.s.w fa0,x0
or
fmsub fa0,fa0,fa0

and then executing:

fmadd.s fa0, fa1, fa2, fa3

gives also zero result.

Not initializing fa3 register, letting all the bits have zero value (this is the value RARS init the FP registers), the same operation gives NAN.
But a FP register with all bits zero should hold FP +0.0.

The same happens with double precision functions: fmadd.d, ...

This was tested with latest version:

rars_533d3c0,jar

@TheThirdOne
Copy link
Owner

Thanks for this issue. This should be fixed by b4943e8. Honestly, I don't know why I made this bug.

TheThirdOne added a commit that referenced this issue Jun 28, 2022
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