[ASan] Rename a atomic_compare_exchange_strong parameter to avoid a compiler warning
[blocksruntime.git] / lib / ppc / gcc_qmul.c
blobfb4c5164ccb59e4fca418a57bb105061a99c88c3
1 /* This file is distributed under the University of Illinois Open Source
2 * License. See LICENSE.TXT for details.
3 */
5 /* long double __gcc_qmul(long double x, long double y);
6 * This file implements the PowerPC 128-bit double-double multiply operation.
7 * This implementation is shamelessly cribbed from Apple's DDRT, circa 1993(!)
8 */
10 #include "DD.h"
12 long double __gcc_qmul(long double x, long double y)
14 static const uint32_t infinityHi = UINT32_C(0x7ff00000);
15 DD dst = { .ld = x }, src = { .ld = y };
17 register double A = dst.s.hi, a = dst.s.lo,
18 B = src.s.hi, b = src.s.lo;
20 double aHi, aLo, bHi, bLo;
21 double ab, tmp, tau;
23 ab = A * B;
25 /* Detect special cases */
26 if (ab == 0.0) {
27 dst.s.hi = ab;
28 dst.s.lo = 0.0;
29 return dst.ld;
32 const doublebits abBits = { .d = ab };
33 if (((uint32_t)(abBits.x >> 32) & infinityHi) == infinityHi) {
34 dst.s.hi = ab;
35 dst.s.lo = 0.0;
36 return dst.ld;
39 /* Generic cases handled here. */
40 aHi = high26bits(A);
41 bHi = high26bits(B);
42 aLo = A - aHi;
43 bLo = B - bHi;
45 tmp = LOWORDER(ab, aHi, aLo, bHi, bLo);
46 tmp += (A * b + a * B);
47 tau = ab + tmp;
49 dst.s.lo = (ab - tau) + tmp;
50 dst.s.hi = tau;
52 return dst.ld;