staticunion ieee754sp _sp_maddf(union ieee754sp z, union ieee754sp x, union ieee754sp y, enum maddf_flags flags)
{ int re; int rs; unsignedint rm;
u64 rm64;
u64 zm64; int s;
COMPXSP;
COMPYSP;
COMPZSP;
EXPLODEXSP;
EXPLODEYSP;
EXPLODEZSP;
FLUSHXSP;
FLUSHYSP;
FLUSHZSP;
ieee754_clearcx();
rs = xs ^ ys; if (flags & MADDF_NEGATE_PRODUCT)
rs ^= 1; if (flags & MADDF_NEGATE_ADDITION)
zs ^= 1;
/* *Handlethecaseswhenatleastoneofx,yorzisaNaN. *OrderofprecedenceissNaN,qNaNandz,x,y.
*/ if (zc == IEEE754_CLASS_SNAN) return ieee754sp_nanxcpt(z); if (xc == IEEE754_CLASS_SNAN) return ieee754sp_nanxcpt(x); if (yc == IEEE754_CLASS_SNAN) return ieee754sp_nanxcpt(y); if (zc == IEEE754_CLASS_QNAN) return z; if (xc == IEEE754_CLASS_QNAN) return x; if (yc == IEEE754_CLASS_QNAN) return y;
if (zc == IEEE754_CLASS_DNORM)
SPDNORMZ; /* ZERO z cases are handled separately below */
switch (CLPAIR(xc, yc)) {
/* *Infinityhandling
*/ case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_ZERO): case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_INF):
ieee754_setcx(IEEE754_INVALID_OPERATION); return ieee754sp_indef();
case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_INF): case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_INF): case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_NORM): case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_DNORM): case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_INF): if ((zc == IEEE754_CLASS_INF) && (zs != rs)) { /* *Casesofadditionofinfinitieswithoppositesigns *orsubtractionofinfinitieswithsamesigns.
*/
ieee754_setcx(IEEE754_INVALID_OPERATION); return ieee754sp_indef();
} /* *zishereeithernotaninfinity,oraninfinityhavingthe *samesignasproduct(x*y).Theresultmustbeaninfinity, *anditssignisdeterminedonlybythesignofproduct(x*y).
*/ return ieee754sp_inf(rs);
case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_ZERO): case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_NORM): case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_DNORM): case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_ZERO): case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_ZERO): if (zc == IEEE754_CLASS_INF) return ieee754sp_inf(zs); if (zc == IEEE754_CLASS_ZERO) { /* Handle cases +0 + (-0) and similar ones. */ if (zs == rs) /* *Casesofadditionofzerosofequalsigns *orsubtractionofzeroesofoppositesigns. *Thesignoftheresultingzeroisinany *suchcasedeterminedonlybythesignofz.
*/ return z;
return ieee754sp_zero(ieee754_csr.rm == FPU_CSR_RD);
} /* x*y is here 0, and z is not 0, so just return z */ return z;
case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_DNORM):
SPDNORMX;
fallthrough; case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_DNORM): if (zc == IEEE754_CLASS_INF) return ieee754sp_inf(zs);
SPDNORMY; break;
case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_NORM): if (zc == IEEE754_CLASS_INF) return ieee754sp_inf(zs);
SPDNORMX; break;
case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_NORM): if (zc == IEEE754_CLASS_INF) return ieee754sp_inf(zs); /* continue to real computations */
}
/* Move explicit bit from bit 23 to bit 62 */
zm64 = (uint64_t)zm << (62 - 23);
assert(zm64 & (1 << 62));
/* Make the exponents the same */ if (ze > re) { /* *Havetoshiftrfractionrighttoalign.
*/
s = ze - re;
rm64 = XSPSRS64(rm64, s);
re += s;
} elseif (re > ze) { /* *Havetoshiftzfractionrighttoalign.
*/
s = re - ze;
zm64 = XSPSRS64(zm64, s);
ze += s;
}
assert(ze == re);
assert(ze <= SP_EMAX);
/* Do the addition */ if (zs == rs) { /* *Generate64bitresultbyaddingtwo63bitnumbers *leavingresultinzm64,zsandze.
*/
zm64 = zm64 + rm64; if ((int64_t)zm64 < 0) { /* carry out */
zm64 = XSPSRS1(zm64);
ze++;
}
} else { if (zm64 >= rm64) {
zm64 = zm64 - rm64;
} else {
zm64 = rm64 - zm64;
zs = rs;
} if (zm64 == 0) return ieee754sp_zero(ieee754_csr.rm == FPU_CSR_RD);
union ieee754sp ieee754sp_maddf(union ieee754sp z, union ieee754sp x, union ieee754sp y)
{ return _sp_maddf(z, x, y, 0);
}
union ieee754sp ieee754sp_msubf(union ieee754sp z, union ieee754sp x, union ieee754sp y)
{ return _sp_maddf(z, x, y, MADDF_NEGATE_PRODUCT);
}
union ieee754sp ieee754sp_madd(union ieee754sp z, union ieee754sp x, union ieee754sp y)
{ return _sp_maddf(z, x, y, 0);
}
union ieee754sp ieee754sp_msub(union ieee754sp z, union ieee754sp x, union ieee754sp y)
{ return _sp_maddf(z, x, y, MADDF_NEGATE_ADDITION);
}
union ieee754sp ieee754sp_nmadd(union ieee754sp z, union ieee754sp x, union ieee754sp y)
{ return _sp_maddf(z, x, y, MADDF_NEGATE_PRODUCT|MADDF_NEGATE_ADDITION);
}
union ieee754sp ieee754sp_nmsub(union ieee754sp z, union ieee754sp x, union ieee754sp y)
{ return _sp_maddf(z, x, y, MADDF_NEGATE_PRODUCT);
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.1 Sekunden
(vorverarbeitet am 2026-09-28)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.