1 /* ===-- mulsc3.c - Implement __mulsc3 -------------------------------------===
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 __mulsc3 for the compiler_rt library.
12 * ===----------------------------------------------------------------------===
19 /* Returns: the product of a + ib and c + id */
22 __mulsc3(float __a, float __b, float __c, float __d)
24 float __ac = __a * __c;
25 float __bd = __b * __d;
26 float __ad = __a * __d;
27 float __bc = __b * __c;
29 __real__ z = __ac - __bd;
30 __imag__ z = __ad + __bc;
31 if (isnan(__real__ z) && isnan(__imag__ z))
34 if (isinf(__a) || isinf(__b))
36 __a = copysignf(isinf(__a) ? 1 : 0, __a);
37 __b = copysignf(isinf(__b) ? 1 : 0, __b);
39 __c = copysignf(0, __c);
41 __d = copysignf(0, __d);
44 if (isinf(__c) || isinf(__d))
46 __c = copysignf(isinf(__c) ? 1 : 0, __c);
47 __d = copysignf(isinf(__d) ? 1 : 0, __d);
49 __a = copysignf(0, __a);
51 __b = copysignf(0, __b);
54 if (!__recalc && (isinf(__ac) || isinf(__bd) ||
55 isinf(__ad) || isinf(__bc)))
58 __a = copysignf(0, __a);
60 __b = copysignf(0, __b);
62 __c = copysignf(0, __c);
64 __d = copysignf(0, __d);
69 __real__ z = INFINITY * (__a * __c - __b * __d);
70 __imag__ z = INFINITY * (__a * __d + __b * __c);