[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / compiler-rt / test / builtins / Unit / netf2_test.c
blobeeeff01ef09c0388930c0f59b24dc06f7d6a4b29
1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_comparetf2
3 //===------------ netf2_test.c - Test __netf2------------------------------===//
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 __netf2 for the compiler_rt library.
13 //===----------------------------------------------------------------------===//
15 #include <stdio.h>
17 #if __LP64__ && __LDBL_MANT_DIG__ == 113
19 #include "fp_test.h"
21 int __netf2(long double a, long double b);
23 int test__netf2(long double a, long double b, enum EXPECTED_RESULT expected)
25 int x = __netf2(a, b);
26 int ret = compareResultCMP(x, expected);
28 if (ret){
29 printf("error in test__netf2(%.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__netf2(makeQNaN128(),
44 0x1.234567890abcdef1234567890abcp+3L,
45 NEQUAL_0))
46 return 1;
47 // <
48 // exp
49 if (test__netf2(0x1.234567890abcdef1234567890abcp-3L,
50 0x1.234567890abcdef1234567890abcp+3L,
51 NEQUAL_0))
52 return 1;
53 // mantissa
54 if (test__netf2(0x1.234567890abcdef1234567890abcp+3L,
55 0x1.334567890abcdef1234567890abcp+3L,
56 NEQUAL_0))
57 return 1;
58 // sign
59 if (test__netf2(-0x1.234567890abcdef1234567890abcp+3L,
60 0x1.234567890abcdef1234567890abcp+3L,
61 NEQUAL_0))
62 return 1;
63 // ==
64 if (test__netf2(0x1.234567890abcdef1234567890abcp+3L,
65 0x1.234567890abcdef1234567890abcp+3L,
66 EQUAL_0))
67 return 1;
68 // >
69 // exp
70 if (test__netf2(0x1.234567890abcdef1234567890abcp+3L,
71 0x1.234567890abcdef1234567890abcp-3L,
72 NEQUAL_0))
73 return 1;
74 // mantissa
75 if (test__netf2(0x1.334567890abcdef1234567890abcp+3L,
76 0x1.234567890abcdef1234567890abcp+3L,
77 NEQUAL_0))
78 return 1;
79 // sign
80 if (test__netf2(0x1.234567890abcdef1234567890abcp+3L,
81 -0x1.234567890abcdef1234567890abcp+3L,
82 NEQUAL_0))
83 return 1;
85 #else
86 printf("skipped\n");
88 #endif
89 return 0;