1 //===-- multc3.c - Implement __multc3 -------------------------------------===//
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 __multc3 for the compiler_rt library.
11 //===----------------------------------------------------------------------===//
13 #define QUAD_PRECISION
18 #if defined(CRT_HAS_TF_MODE)
20 // Returns: the product of a + ib and c + id
22 COMPILER_RT_ABI Qcomplex
__multc3(fp_t a
, fp_t b
, fp_t c
, fp_t d
) {
28 COMPLEXTF_REAL(z
) = ac
- bd
;
29 COMPLEXTF_IMAGINARY(z
) = ad
+ bc
;
30 if (crt_isnan(COMPLEXTF_REAL(z
)) && crt_isnan(COMPLEXTF_IMAGINARY(z
))) {
32 if (crt_isinf(a
) || crt_isinf(b
)) {
33 a
= crt_copysigntf(crt_isinf(a
) ? 1 : 0, a
);
34 b
= crt_copysigntf(crt_isinf(b
) ? 1 : 0, b
);
36 c
= crt_copysigntf(0, c
);
38 d
= crt_copysigntf(0, d
);
41 if (crt_isinf(c
) || crt_isinf(d
)) {
42 c
= crt_copysigntf(crt_isinf(c
) ? 1 : 0, c
);
43 d
= crt_copysigntf(crt_isinf(d
) ? 1 : 0, d
);
45 a
= crt_copysigntf(0, a
);
47 b
= crt_copysigntf(0, b
);
51 (crt_isinf(ac
) || crt_isinf(bd
) || crt_isinf(ad
) || crt_isinf(bc
))) {
53 a
= crt_copysigntf(0, a
);
55 b
= crt_copysigntf(0, b
);
57 c
= crt_copysigntf(0, c
);
59 d
= crt_copysigntf(0, d
);
63 COMPLEXTF_REAL(z
) = CRT_INFINITY
* (a
* c
- b
* d
);
64 COMPLEXTF_IMAGINARY(z
) = CRT_INFINITY
* (a
* d
+ b
* c
);