[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / compiler-rt / test / builtins / Unit / fixtfsi_test.c
blobe679992e88f836e6bff7626992aba9136ed7c13d
1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_fixtfsi
3 //===--------------- fixtfsi_test.c - Test __fixtfsi ----------------------===//
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 __fixtfsi for the compiler_rt library.
13 //===----------------------------------------------------------------------===//
15 #include <stdio.h>
17 #if __LDBL_MANT_DIG__ == 113
19 #include "fp_test.h"
21 int __fixtfsi(long double a);
23 int test__fixtfsi(long double a, int expected)
25 int x = __fixtfsi(a);
26 int ret = (x != expected);
28 if (ret){
29 printf("error in test__fixtfsi(%.20Lf) = %d, "
30 "expected %d\n", a, x, expected);
32 return ret;
35 char assumption_1[sizeof(long double) * CHAR_BIT == 128] = {0};
37 #endif
39 int main()
41 #if __LDBL_MANT_DIG__ == 113
42 if (test__fixtfsi(makeInf128(), 0x7fffffff))
43 return 1;
44 if (test__fixtfsi(0, 0x0))
45 return 1;
46 if (test__fixtfsi(0x1.23456789abcdefp+5, 0x24))
47 return 1;
48 if (test__fixtfsi(0x1.23456789abcdefp-3, 0x0))
49 return 1;
50 if (test__fixtfsi(0x1.23456789abcdefp+20, 0x123456))
51 return 1;
52 if (test__fixtfsi(0x1.23456789abcdefp+40, 0x7fffffff))
53 return 1;
54 if (test__fixtfsi(0x1.23456789abcdefp+256, 0x7fffffff))
55 return 1;
56 if (test__fixtfsi(-0x1.23456789abcdefp+20, 0xffedcbaa))
57 return 1;
58 if (test__fixtfsi(-0x1.23456789abcdefp+40, 0x80000000))
59 return 1;
61 #else
62 printf("skipped\n");
64 #endif
65 return 0;