blob: 4fad9060f0df37e27b0fc33c5405d85660d7a159 [file] [log] [blame]
Weiming Zhao9b7bbec2017-03-21 05:32:51 +00001// RUN: %clang_builtins %s %librt -o %t && %run %t
Joerg Sonnenbergerfee19282014-05-29 01:00:39 +00002//===--------------- extendsftf2_test.c - Test __extendsftf2 --------------===//
3//
4// The LLVM Compiler Infrastructure
5//
6// This file is dual licensed under the MIT and the University of Illinois Open
7// Source Licenses. See LICENSE.TXT for details.
8//
9//===----------------------------------------------------------------------===//
10//
11// This file tests __extendsftf2 for the compiler_rt library.
12//
13//===----------------------------------------------------------------------===//
14
Derek Schuffeb0ebc32015-04-24 15:45:57 +000015#include "int_lib.h"
Joerg Sonnenbergerfee19282014-05-29 01:00:39 +000016#include <stdio.h>
17
18#if __LDBL_MANT_DIG__ == 113
19
20#include "fp_test.h"
21
Derek Schuffeb0ebc32015-04-24 15:45:57 +000022COMPILER_RT_ABI long double __extendsftf2(float a);
Joerg Sonnenbergerfee19282014-05-29 01:00:39 +000023
24int test__extendsftf2(float a, uint64_t expectedHi, uint64_t expectedLo)
25{
26 long double x = __extendsftf2(a);
27 int ret = compareResultLD(x, expectedHi, expectedLo);
28
29 if (ret)
30 {
31 printf("error in test__extendsftf2(%f) = %.20Lf, "
32 "expected %.20Lf\n", a, x, fromRep128(expectedHi, expectedLo));
33 }
34 return ret;
35}
36
37char assumption_1[sizeof(long double) * CHAR_BIT == 128] = {0};
38
39#endif
40
41int main()
42{
43#if __LDBL_MANT_DIG__ == 113
44 // qNaN
45 if (test__extendsftf2(makeQNaN32(),
46 UINT64_C(0x7fff800000000000),
47 UINT64_C(0x0)))
48 return 1;
49 // NaN
50 if (test__extendsftf2(makeNaN32(UINT32_C(0x410000)),
51 UINT64_C(0x7fff820000000000),
52 UINT64_C(0x0)))
53 return 1;
54 // inf
55 if (test__extendsftf2(makeInf32(),
56 UINT64_C(0x7fff000000000000),
57 UINT64_C(0x0)))
58 return 1;
59 // zero
60 if (test__extendsftf2(0.0f, UINT64_C(0x0), UINT64_C(0x0)))
61 return 1;
62
63 if (test__extendsftf2(0x1.23456p+5f,
64 UINT64_C(0x4004234560000000),
65 UINT64_C(0x0)))
66 return 1;
67 if (test__extendsftf2(0x1.edcbap-9f,
68 UINT64_C(0x3ff6edcba0000000),
69 UINT64_C(0x0)))
70 return 1;
71 if (test__extendsftf2(0x1.23456p+45f,
72 UINT64_C(0x402c234560000000),
73 UINT64_C(0x0)))
74 return 1;
75 if (test__extendsftf2(0x1.edcbap-45f,
76 UINT64_C(0x3fd2edcba0000000),
77 UINT64_C(0x0)))
78 return 1;
79
80#else
81 printf("skipped\n");
82
83#endif
84 return 0;
85}