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 * ===----------------------------------------------------------------------===
20 /* Returns: the product of a + ib and c + id */
23 __mulxc3(long double __a
, long double __b
, long double __c
, long double __d
)
25 long double __ac
= __a
* __c
;
26 long double __bd
= __b
* __d
;
27 long double __ad
= __a
* __d
;
28 long double __bc
= __b
* __c
;
29 long double _Complex z
;
30 __real__ z
= __ac
- __bd
;
31 __imag__ z
= __ad
+ __bc
;
32 if (crt_isnan(__real__ z
) && crt_isnan(__imag__ z
))
35 if (crt_isinf(__a
) || crt_isinf(__b
))
37 __a
= crt_copysignl(crt_isinf(__a
) ? 1 : 0, __a
);
38 __b
= crt_copysignl(crt_isinf(__b
) ? 1 : 0, __b
);
40 __c
= crt_copysignl(0, __c
);
42 __d
= crt_copysignl(0, __d
);
45 if (crt_isinf(__c
) || crt_isinf(__d
))
47 __c
= crt_copysignl(crt_isinf(__c
) ? 1 : 0, __c
);
48 __d
= crt_copysignl(crt_isinf(__d
) ? 1 : 0, __d
);
50 __a
= crt_copysignl(0, __a
);
52 __b
= crt_copysignl(0, __b
);
55 if (!__recalc
&& (crt_isinf(__ac
) || crt_isinf(__bd
) ||
56 crt_isinf(__ad
) || crt_isinf(__bc
)))
59 __a
= crt_copysignl(0, __a
);
61 __b
= crt_copysignl(0, __b
);
63 __c
= crt_copysignl(0, __c
);
65 __d
= crt_copysignl(0, __d
);
70 __real__ z
= CRT_INFINITY
* (__a
* __c
- __b
* __d
);
71 __imag__ z
= CRT_INFINITY
* (__a
* __d
+ __b
* __c
);