Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / builtins / Unit / fixunstfsi_test.c
blob64ea023cde8d37db16ec7d42c54f5694d22ce613
1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_fixunstfsi
4 #include <stdio.h>
6 #if __LDBL_MANT_DIG__ == 113
8 #include "fp_test.h"
10 unsigned int __fixunstfsi(long double a);
12 int test__fixunstfsi(long double a, unsigned int expected)
14 unsigned int x = __fixunstfsi(a);
15 int ret = (x != expected);
17 if (ret)
19 printf("error in test__fixunstfsi(%.20Lf) = %u, "
20 "expected %u\n", a, x, expected);
22 return ret;
25 char assumption_1[sizeof(long double) * CHAR_BIT == 128] = {0};
27 #endif
29 int main()
31 #if __LDBL_MANT_DIG__ == 113
32 if (test__fixunstfsi(makeInf128(), UINT32_C(0xffffffff)))
33 return 1;
34 if (test__fixunstfsi(0, UINT32_C(0x0)))
35 return 1;
36 if (test__fixunstfsi(0x1.23456789abcdefp+5, UINT32_C(0x24)))
37 return 1;
38 if (test__fixunstfsi(0x1.23456789abcdefp-3, UINT32_C(0x0)))
39 return 1;
40 if (test__fixunstfsi(0x1.23456789abcdefp+20, UINT32_C(0x123456)))
41 return 1;
42 if (test__fixunstfsi(0x1.23456789abcdefp+40, UINT32_C(0xffffffff)))
43 return 1;
44 if (test__fixunstfsi(0x1.23456789abcdefp+256, UINT32_C(0xffffffff)))
45 return 1;
46 if (test__fixunstfsi(-0x1.23456789abcdefp+3, UINT32_C(0x0)))
47 return 1;
49 if (test__fixunstfsi(0x1.p+32, 0xFFFFFFFFLL))
50 return 1;
52 #else
53 printf("skipped\n");
55 #endif
56 return 0;