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_qdiv(long double x, long double y);
6 // This file implements the PowerPC 128-bit double-double division operation.
7 // This implementation is shamelessly cribbed from Apple's DDRT, circa 1993(!)
11 long double __gcc_qdiv(long double a, long double b) {
12 static const uint32_t infinityHi = UINT32_C(0x7ff00000);
13 DD dst = {.ld = a}, src = {.ld = b};
15 register double x = dst.s.hi, x1 = dst.s.lo, y = src.s.hi, y1 = src.s.lo;
17 double yHi, yLo, qHi, qLo;
22 // Detect special cases
29 const doublebits qBits = {.d = q};
30 if (((uint32_t)(qBits.x >> 32) & infinityHi) == infinityHi) {
43 tmp = LOWORDER(yq, yHi, yLo, qHi, qLo);
45 tmp = ((tmp + x1) - y1 * q) / y;
48 dst.s.lo = (q - x) + tmp;