staticunion ieee754dp _dp_maddf(union ieee754dp z, union ieee754dp x, union ieee754dp y, enum maddf_flags flags)
{ int re; int rs; unsignedint lxm; unsignedint hxm; unsignedint lym; unsignedint hym;
u64 lrm;
u64 hrm;
u64 lzm;
u64 hzm;
u64 t;
u64 at; int s;
COMPXDP;
COMPYDP;
COMPZDP;
EXPLODEXDP;
EXPLODEYDP;
EXPLODEZDP;
FLUSHXDP;
FLUSHYDP;
FLUSHZDP;
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 ieee754dp_nanxcpt(z); if (xc == IEEE754_CLASS_SNAN) return ieee754dp_nanxcpt(x); if (yc == IEEE754_CLASS_SNAN) return ieee754dp_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)
DPDNORMZ; /* 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 ieee754dp_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 ieee754dp_indef();
} /* *zishereeithernotaninfinity,oraninfinityhavingthe *samesignasproduct(x*y).Theresultmustbeaninfinity, *anditssignisdeterminedonlybythesignofproduct(x*y).
*/ return ieee754dp_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 ieee754dp_inf(zs); if (zc == IEEE754_CLASS_ZERO) { /* Handle cases +0 + (-0) and similar ones. */ if (zs == rs) /* *Casesofadditionofzerosofequalsigns *orsubtractionofzeroesofoppositesigns. *Thesignoftheresultingzeroisinany *suchcasedeterminedonlybythesignofz.
*/ return z;
return ieee754dp_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):
DPDNORMX;
fallthrough; case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_DNORM): if (zc == IEEE754_CLASS_INF) return ieee754dp_inf(zs);
DPDNORMY; break;
case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_NORM): if (zc == IEEE754_CLASS_INF) return ieee754dp_inf(zs);
DPDNORMX; break;
case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_NORM): if (zc == IEEE754_CLASS_INF) return ieee754dp_inf(zs); /* continue to real computations */
}
/* Put explicit bit at bit 126 if necessary */ if ((int64_t)hrm < 0) {
lrm = (hrm << 63) | (lrm >> 1);
hrm = hrm >> 1;
re++;
}
assert(hrm & (1 << 62));
if (zc == IEEE754_CLASS_ZERO) { /* *Moveexplicitbitfrombit126tobit55sincethe *ieee754dp_formatcodeexpectsthemantissatobe *56bitswide(53+3roundingbits).
*/
srl128(&hrm, &lrm, (126 - 55)); return ieee754dp_format(rs, re, lrm);
}
/* Move explicit bit from bit 52 to bit 126 */
lzm = 0;
hzm = zm << 10;
assert(hzm & (1 << 62));
/* Make the exponents the same */ if (ze > re) { /* *Havetoshiftyfractionrighttoalign.
*/
s = ze - re;
srl128(&hrm, &lrm, s);
re += s;
} elseif (re > ze) { /* *Havetoshiftxfractionrighttoalign.
*/
s = re - ze;
srl128(&hzm, &lzm, s);
ze += s;
}
assert(ze == re);
assert(ze <= DP_EMAX);
union ieee754dp ieee754dp_maddf(union ieee754dp z, union ieee754dp x, union ieee754dp y)
{ return _dp_maddf(z, x, y, 0);
}
union ieee754dp ieee754dp_msubf(union ieee754dp z, union ieee754dp x, union ieee754dp y)
{ return _dp_maddf(z, x, y, MADDF_NEGATE_PRODUCT);
}
union ieee754dp ieee754dp_madd(union ieee754dp z, union ieee754dp x, union ieee754dp y)
{ return _dp_maddf(z, x, y, 0);
}
union ieee754dp ieee754dp_msub(union ieee754dp z, union ieee754dp x, union ieee754dp y)
{ return _dp_maddf(z, x, y, MADDF_NEGATE_ADDITION);
}
union ieee754dp ieee754dp_nmadd(union ieee754dp z, union ieee754dp x, union ieee754dp y)
{ return _dp_maddf(z, x, y, MADDF_NEGATE_PRODUCT|MADDF_NEGATE_ADDITION);
}
union ieee754dp ieee754dp_nmsub(union ieee754dp z, union ieee754dp x, union ieee754dp y)
{ return _dp_maddf(z, x, y, MADDF_NEGATE_PRODUCT);
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet am 2026-09-27)
¤
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.