Skip to content

fmadd / fmsub error when adding with zero #158

@helderdaniel

Description

@helderdaniel

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions