1 /* ===-- mulxc3.c - Implement __mulxc3 -------------------------------------===
3 * The LLVM Compiler Infrastructure
5 * This file is dual licensed under the MIT and the University of Illinois Open
6 * Source Licenses. See LICENSE.TXT for details.
8 * ===----------------------------------------------------------------------===
10 * This file implements __mulxc3 for the compiler_rt library.
12 * ===----------------------------------------------------------------------===
21 /* Returns: the product of a + ib and c + id */
24 __mulxc3(long double __a, long double __b, long double __c, long double __d)
26 long double __ac = __a * __c;
27 long double __bd = __b * __d;
28 long double __ad = __a * __d;
29 long double __bc = __b * __c;
30 long double _Complex z;
31 __real__ z = __ac - __bd;
32 __imag__ z = __ad + __bc;
33 if (isnan(__real__ z) && isnan(__imag__ z))
36 if (isinf(__a) || isinf(__b))
38 __a = copysignl(isinf(__a) ? 1 : 0, __a);
39 __b = copysignl(isinf(__b) ? 1 : 0, __b);
41 __c = copysignl(0, __c);
43 __d = copysignl(0, __d);
46 if (isinf(__c) || isinf(__d))
48 __c = copysignl(isinf(__c) ? 1 : 0, __c);
49 __d = copysignl(isinf(__d) ? 1 : 0, __d);
51 __a = copysignl(0, __a);
53 __b = copysignl(0, __b);
56 if (!__recalc && (isinf(__ac) || isinf(__bd) ||
57 isinf(__ad) || isinf(__bc)))
60 __a = copysignl(0, __a);
62 __b = copysignl(0, __b);
64 __c = copysignl(0, __c);
66 __d = copysignl(0, __d);
71 __real__ z = INFINITY * (__a * __c - __b * __d);
72 __imag__ z = INFINITY * (__a * __d + __b * __c);