fixes concerning FMADD_S, FMSUB_S, FNMADD_S, and FNSUB_S

mostly about ensuring correct sign
This commit is contained in:
2024-07-29 21:07:54 +02:00
parent 93d89e07ca
commit 7ffa7667b6
2 changed files with 13 additions and 3 deletions

View File

@ -149,11 +149,17 @@ uint32_t fcvt_s(uint32_t v1, uint32_t op, uint8_t mode) {
}
uint32_t fmadd_s(uint32_t v1, uint32_t v2, uint32_t v3, uint32_t op, uint8_t mode) {
// Used values for op are:
// FMADD_S: 0b00
// FMSUB_S: 0b01
// FNMADD_S: 0b10
// FNMSUB_S: 0b11
// op should be {softfloat_mulAdd_subProd(2), softfloat_mulAdd_subC(1)}
softfloat_roundingMode = rmm_map[mode & 0x7];
softfloat_exceptionFlags = 0;
float32_t res = softfloat_mulAddF32(v1, v2, v3, op & 0x1);
if(op > 1)
// Do not invert quiet NaN
if((op & 0b10) && (res.v != quiet_nan32))
res.v ^= 1ULL << 31;
return res.v;
}