1 /* ===-- muldc3.c - Implement __muldc3 -------------------------------------===
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 __muldc3 for the compiler_rt library.
12 * ===----------------------------------------------------------------------===
18 /* Returns: the product of a + ib and c + id */
21 __muldc3(double __a
, double __b
, double __c
, double __d
)
23 double __ac
= __a
* __c
;
24 double __bd
= __b
* __d
;
25 double __ad
= __a
* __d
;
26 double __bc
= __b
* __c
;
28 __real__ z
= __ac
- __bd
;
29 __imag__ z
= __ad
+ __bc
;
30 if (crt_isnan(__real__ z
) && crt_isnan(__imag__ z
))
33 if (crt_isinf(__a
) || crt_isinf(__b
))
35 __a
= crt_copysign(crt_isinf(__a
) ? 1 : 0, __a
);
36 __b
= crt_copysign(crt_isinf(__b
) ? 1 : 0, __b
);
38 __c
= crt_copysign(0, __c
);
40 __d
= crt_copysign(0, __d
);
43 if (crt_isinf(__c
) || crt_isinf(__d
))
45 __c
= crt_copysign(crt_isinf(__c
) ? 1 : 0, __c
);
46 __d
= crt_copysign(crt_isinf(__d
) ? 1 : 0, __d
);
48 __a
= crt_copysign(0, __a
);
50 __b
= crt_copysign(0, __b
);
53 if (!__recalc
&& (crt_isinf(__ac
) || crt_isinf(__bd
) ||
54 crt_isinf(__ad
) || crt_isinf(__bc
)))
57 __a
= crt_copysign(0, __a
);
59 __b
= crt_copysign(0, __b
);
61 __c
= crt_copysign(0, __c
);
63 __d
= crt_copysign(0, __d
);
68 __real__ z
= CRT_INFINITY
* (__a
* __c
- __b
* __d
);
69 __imag__ z
= CRT_INFINITY
* (__a
* __d
+ __b
* __c
);