[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / compiler-rt / test / builtins / Unit / lttf2_test.c
blob0f3ea9e67478ff25f073bed761b46d0f9b6a8201
1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_comparetf2
3 //===------------ lttf2_test.c - Test __lttf2------------------------------===//
4 //
5 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
6 // See https://llvm.org/LICENSE.txt for license information.
7 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 //
9 //===----------------------------------------------------------------------===//
11 // This file tests __lttf2 for the compiler_rt library.
13 //===----------------------------------------------------------------------===//
15 #include <stdio.h>
17 #if __LP64__ && __LDBL_MANT_DIG__ == 113
19 #include "fp_test.h"
21 int __lttf2(long double a, long double b);
23 int test__lttf2(long double a, long double b, enum EXPECTED_RESULT expected)
25 int x = __lttf2(a, b);
26 int ret = compareResultCMP(x, expected);
28 if (ret){
29 printf("error in test__lttf2(%.20Lf, %.20Lf) = %d, "
30 "expected %s\n", a, b, x, expectedStr(expected));
32 return ret;
35 char assumption_1[sizeof(long double) * CHAR_BIT == 128] = {0};
37 #endif
39 int main()
41 #if __LP64__ && __LDBL_MANT_DIG__ == 113
42 // NaN
43 if (test__lttf2(makeQNaN128(),
44 0x1.234567890abcdef1234567890abcp+3L,
45 GREATER_EQUAL_0))
46 return 1;
47 // <
48 // exp
49 if (test__lttf2(0x1.234567890abcdef1234567890abcp-3L,
50 0x1.234567890abcdef1234567890abcp+3L,
51 LESS_0))
52 return 1;
53 // mantissa
54 if (test__lttf2(0x1.234567890abcdef1234567890abcp+3L,
55 0x1.334567890abcdef1234567890abcp+3L,
56 LESS_0))
57 return 1;
58 // sign
59 if (test__lttf2(-0x1.234567890abcdef1234567890abcp+3L,
60 0x1.234567890abcdef1234567890abcp+3L,
61 LESS_0))
62 return 1;
63 // ==
64 if (test__lttf2(0x1.234567890abcdef1234567890abcp+3L,
65 0x1.234567890abcdef1234567890abcp+3L,
66 GREATER_EQUAL_0))
67 return 1;
68 // >
69 // exp
70 if (test__lttf2(0x1.234567890abcdef1234567890abcp+3L,
71 0x1.234567890abcdef1234567890abcp-3L,
72 GREATER_EQUAL_0))
73 return 1;
74 // mantissa
75 if (test__lttf2(0x1.334567890abcdef1234567890abcp+3L,
76 0x1.234567890abcdef1234567890abcp+3L,
77 GREATER_EQUAL_0))
78 return 1;
79 // sign
80 if (test__lttf2(0x1.234567890abcdef1234567890abcp+3L,
81 -0x1.234567890abcdef1234567890abcp+3L,
82 GREATER_EQUAL_0))
83 return 1;
85 #else
86 printf("skipped\n");
88 #endif
89 return 0;