[compiler-rt] [llvm] Add extendhfxf2 into compiler rt (PR #111099)
B I Mohammed Abbas via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 24 23:17:30 PDT 2024
================
@@ -0,0 +1,67 @@
+// RUN: %clang_builtins %s %librt -o %t && %run %t
+// REQUIRES: librt_has_extendhfxf2
+
+#include <limits.h>
+#include <math.h> // for isnan, isinf
+#include <stdio.h>
+
+#if __LDBL_MANT_DIG__ >= 64 && defined(COMPILER_RT_HAS_FLOAT16)
+long double __extendhfxf2(_Float16 f);
+
+int test_extendhfxf2(_Float16 a, long double expected) {
+ long double x = __extendhfxf2(a);
+ __uint16_t *b = (void *)&a;
+ int ret = !(x == expected || (isnan(x) && isnan(expected)) ||
+ (isinf(x) && isinf(expected) && x == expected));
+ if (ret) {
+ printf("error in test__extendhfxf2(%#.4x) = %.20Lf, "
+ "expected %.20Lf\n",
+ *b, x, expected);
+ }
+ return ret;
+}
+
+char assumption_1[sizeof(_Float16) * CHAR_BIT == 16] = {0};
+
+#endif
+
+int main() {
----------------
biabbas wrote:
Yeah. I think this would be clearer.
https://github.com/llvm/llvm-project/pull/111099
More information about the llvm-commits
mailing list