96 lines · c
1// RUN: %clang_builtins %s %librt -o %t && %run %t2// REQUIRES: librt_has_extendhftf23 4#include "int_lib.h"5#include <stdio.h>6 7#if __LDBL_MANT_DIG__ == 113 && defined(COMPILER_RT_HAS_FLOAT16)8 9#include "fp_test.h"10 11COMPILER_RT_ABI long double __extendhftf2(TYPE_FP16 a);12 13int test__extendhftf2(TYPE_FP16 a, uint64_t expectedHi, uint64_t expectedLo) {14 long double x = __extendhftf2(a);15 int ret = compareResultF128(x, expectedHi, expectedLo);16 17 if (ret) {18 printf("error in test__extendhftf2(%#.4x) = %.20Lf, "19 "expected %.20Lf\n",20 toRep16(a), x,21 fromRep128(expectedHi, expectedLo));22 }23 return ret;24}25 26char assumption_1[sizeof(TYPE_FP16) * CHAR_BIT == 16] = {0};27 28#endif29 30int main() {31#if __LDBL_MANT_DIG__ == 113 && defined(COMPILER_RT_HAS_FLOAT16)32 // qNaN33 if (test__extendhftf2(makeQNaN16(),34 UINT64_C(0x7fff800000000000),35 UINT64_C(0x0)))36 return 1;37 // NaN38 if (test__extendhftf2(makeNaN16(UINT16_C(0x0100)),39 UINT64_C(0x7fff400000000000),40 UINT64_C(0x0)))41 return 1;42 // inf43 if (test__extendhftf2(makeInf16(),44 UINT64_C(0x7fff000000000000),45 UINT64_C(0x0)))46 return 1;47 if (test__extendhftf2(-makeInf16(),48 UINT64_C(0xffff000000000000),49 UINT64_C(0x0)))50 return 1;51 // zero52 if (test__extendhftf2(fromRep16(0x0U),53 UINT64_C(0x0), UINT64_C(0x0)))54 return 1;55 if (test__extendhftf2(fromRep16(0x8000U),56 UINT64_C(0x8000000000000000),57 UINT64_C(0x0)))58 return 1;59 // denormal60 if (test__extendhftf2(fromRep16(0x0010U),61 UINT64_C(0x3feb000000000000),62 UINT64_C(0x0000000000000000)))63 return 1;64 if (test__extendhftf2(fromRep16(0x0001U),65 UINT64_C(0x3fe7000000000000),66 UINT64_C(0x0000000000000000)))67 return 1;68 if (test__extendhftf2(fromRep16(0x8001U),69 UINT64_C(0xbfe7000000000000),70 UINT64_C(0x0000000000000000)))71 return 1;72 73 // pi74 if (test__extendhftf2(fromRep16(0x4248U),75 UINT64_C(0x4000920000000000),76 UINT64_C(0x0000000000000000)))77 return 1;78 if (test__extendhftf2(fromRep16(0xc248U),79 UINT64_C(0xc000920000000000),80 UINT64_C(0x0000000000000000)))81 return 1;82 83 if (test__extendhftf2(fromRep16(0x508cU),84 UINT64_C(0x4004230000000000),85 UINT64_C(0x0)))86 return 1;87 if (test__extendhftf2(fromRep16(0x1bb7U),88 UINT64_C(0x3ff6edc000000000),89 UINT64_C(0x0)))90 return 1;91#else92 printf("skipped\n");93#endif94 return 0;95}96