1 //===-- mulxc3_test.c - Test __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 tests __mulxc3 for the compiler_rt library.
12 //===----------------------------------------------------------------------===//
21 // Returns: the product of a + ib and c + id
24 __mulxc3(long double __a
, long double __b
, long double __c
, long double __d
);
26 enum {zero
, non_zero
, inf
, NaN
, non_zero_nan
};
29 classify(long double _Complex x
)
33 if (isinf(creall(x
)) || isinf(cimagl(x
)))
35 if (isnan(creall(x
)) && isnan(cimagl(x
)))
52 int test__mulxc3(long double a
, long double b
, long double c
, long double d
)
54 long double _Complex r
= __mulxc3(a
, b
, c
, d
);
55 // printf("test__mulxc3(%Lf, %Lf, %Lf, %Lf) = %Lf + I%Lf\n",
56 // a, b, c, d, creall(r), cimagl(r));
57 long double _Complex dividend
;
58 long double _Complex divisor
;
60 __real__ dividend
= a
;
61 __imag__ dividend
= b
;
65 switch (classify(dividend
))
68 switch (classify(divisor
))
71 if (classify(r
) != zero
)
75 if (classify(r
) != zero
)
79 if (classify(r
) != NaN
)
83 if (classify(r
) != NaN
)
87 if (classify(r
) != NaN
)
93 switch (classify(divisor
))
96 if (classify(r
) != zero
)
100 if (classify(r
) != non_zero
)
102 if (r
!= a
* c
- b
* d
+ _Complex_I
*(a
* d
+ b
* c
))
106 if (classify(r
) != inf
)
110 if (classify(r
) != NaN
)
114 if (classify(r
) != NaN
)
120 switch (classify(divisor
))
123 if (classify(r
) != NaN
)
127 if (classify(r
) != inf
)
131 if (classify(r
) != inf
)
135 if (classify(r
) != NaN
)
139 if (classify(r
) != inf
)
145 switch (classify(divisor
))
148 if (classify(r
) != NaN
)
152 if (classify(r
) != NaN
)
156 if (classify(r
) != NaN
)
160 if (classify(r
) != NaN
)
164 if (classify(r
) != NaN
)
170 switch (classify(divisor
))
173 if (classify(r
) != NaN
)
177 if (classify(r
) != NaN
)
181 if (classify(r
) != inf
)
185 if (classify(r
) != NaN
)
189 if (classify(r
) != NaN
)
234 {-INFINITY
, -INFINITY
},
243 {INFINITY
, -INFINITY
},
342 {-INFINITY
, INFINITY
},
360 const unsigned N
= sizeof(x
) / sizeof(x
[0]);
362 for (i
= 0; i
< N
; ++i
)
364 for (j
= 0; j
< N
; ++j
)
366 if (test__mulxc3(x
[i
][0], x
[i
][1], x
[j
][0], x
[j
][1]))