1 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
2 // See https://llvm.org/LICENSE.txt for license information.
3 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
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(!)
11 long double __gcc_qmul(long double x
, long double y
) {
12 static const uint32_t infinityHi
= UINT32_C(0x7ff00000);
13 DD dst
= {.ld
= x
}, src
= {.ld
= y
};
15 register double A
= dst
.s
.hi
, a
= dst
.s
.lo
, B
= src
.s
.hi
, b
= src
.s
.lo
;
17 double aHi
, aLo
, bHi
, bLo
;
22 // Detect special cases
29 const doublebits abBits
= {.d
= ab
};
30 if (((uint32_t)(abBits
.x
>> 32) & infinityHi
) == infinityHi
) {
36 // Generic cases handled here.
42 tmp
= LOWORDER(ab
, aHi
, aLo
, bHi
, bLo
);
43 tmp
+= (A
* b
+ a
* B
);
46 dst
.s
.lo
= (ab
- tau
) + tmp
;