1 //===-- mulxc3.c - Implement __mulxc3 -------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file implements __mulxc3 for the compiler_rt library.
11 //===----------------------------------------------------------------------===//
18 // Returns: the product of a + ib and c + id
20 COMPILER_RT_ABI Lcomplex
__mulxc3(xf_float __a
, xf_float __b
, xf_float __c
,
22 xf_float __ac
= __a
* __c
;
23 xf_float __bd
= __b
* __d
;
24 xf_float __ad
= __a
* __d
;
25 xf_float __bc
= __b
* __c
;
27 COMPLEX_REAL(z
) = __ac
- __bd
;
28 COMPLEX_IMAGINARY(z
) = __ad
+ __bc
;
29 if (crt_isnan(COMPLEX_REAL(z
)) && crt_isnan(COMPLEX_IMAGINARY(z
))) {
31 if (crt_isinf(__a
) || crt_isinf(__b
)) {
32 __a
= crt_copysignl(crt_isinf(__a
) ? 1 : 0, __a
);
33 __b
= crt_copysignl(crt_isinf(__b
) ? 1 : 0, __b
);
35 __c
= crt_copysignl(0, __c
);
37 __d
= crt_copysignl(0, __d
);
40 if (crt_isinf(__c
) || crt_isinf(__d
)) {
41 __c
= crt_copysignl(crt_isinf(__c
) ? 1 : 0, __c
);
42 __d
= crt_copysignl(crt_isinf(__d
) ? 1 : 0, __d
);
44 __a
= crt_copysignl(0, __a
);
46 __b
= crt_copysignl(0, __b
);
49 if (!__recalc
&& (crt_isinf(__ac
) || crt_isinf(__bd
) || crt_isinf(__ad
) ||
52 __a
= crt_copysignl(0, __a
);
54 __b
= crt_copysignl(0, __b
);
56 __c
= crt_copysignl(0, __c
);
58 __d
= crt_copysignl(0, __d
);
62 COMPLEX_REAL(z
) = CRT_INFINITY
* (__a
* __c
- __b
* __d
);
63 COMPLEX_IMAGINARY(z
) = CRT_INFINITY
* (__a
* __d
+ __b
* __c
);