Skip to content

Commit

Permalink
softfloat: add xtensa specialization for pickNaNMulAdd
Browse files Browse the repository at this point in the history
pickNaNMulAdd logic on Xtensa is to apply pickNaN to the inputs of the
expression (a * b) + c. However if default NaN is produces as a result
of (a * b) calculation it is not considered when c is NaN.
So with two pickNaN variants there must be two pickNaNMulAdd variants.
In addition the invalid flag is always set when (a * b) produces NaN.

Cc: Peter Maydell <[email protected]>
Cc: "Alex Bennée" <[email protected]>
Cc: Richard Henderson <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Max Filippov <[email protected]>
  • Loading branch information
jcmvbkbc committed Aug 21, 2020
1 parent 913602e commit fbcc38e
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions fpu/softfloat-specialize.c.inc
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,32 @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
} else {
return 1;
}
#elif defined(TARGET_XTENSA)
/*
* For Xtensa, the (inf,zero,nan) case sets InvalidOp and returns
* an input NaN if we have one (ie c).
*/
if (infzero) {
float_raise(float_flag_invalid, status);
return 2;
}
if (status->use_first_nan) {
if (is_nan(a_cls)) {
return 0;
} else if (is_nan(b_cls)) {
return 1;
} else {
return 2;
}
} else {
if (is_nan(c_cls)) {
return 2;
} else if (is_nan(b_cls)) {
return 1;
} else {
return 0;
}
}
#else
/* A default implementation: prefer a to b to c.
* This is unlikely to actually match any real implementation.
Expand Down

0 comments on commit fbcc38e

Please sign in to comment.