[compiler-rt] [llvm] Add missing extendhfxf2 in compiler rt (PR #109090)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 27 06:48:44 PDT 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 09cd5a86733a362f12542a11ffd834cac885eb32 fb2e1e0f3438d0b8a64b3db8756e1e1db11cf9ab --extensions c -- compiler-rt/lib/builtins/extendhfxf2.c compiler-rt/test/builtins/Unit/extendhfxf2_test.c
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/compiler-rt/lib/builtins/extendhfxf2.c b/compiler-rt/lib/builtins/extendhfxf2.c
index ce70c0eaf8..2bd7c3b7c7 100644
--- a/compiler-rt/lib/builtins/extendhfxf2.c
+++ b/compiler-rt/lib/builtins/extendhfxf2.c
@@ -1,4 +1,5 @@
-//===-- lib/extendhfxf2.c - half -> long double conversion -------------*- C -*-===//
+//===-- lib/extendhfxf2.c - half -> long double conversion -------------*- C
+//-*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/compiler-rt/test/builtins/Unit/extendhfxf2_test.c b/compiler-rt/test/builtins/Unit/extendhfxf2_test.c
index 721878c850..567b70a671 100644
--- a/compiler-rt/test/builtins/Unit/extendhfxf2_test.c
+++ b/compiler-rt/test/builtins/Unit/extendhfxf2_test.c
@@ -1,57 +1,60 @@
// RUN: %clang_builtins %s %librt -o %t && %run %t
// REQUIRES: librt_has_extendhfxf2
-#include <stdio.h>
-#include <math.h> // for isnan, isinf
#include <limits.h>
+#include <math.h> // for isnan, isinf
+#include <stdio.h>
long double __extendhfxf2(_Float16 f);
-int test_extendhfxf2(_Float16 a, long double expected)
-{
- long double x = __extendhfxf2(a);
- int ret = !(x == expected || (isnan(x) && isnan(expected)) || (isinf(x) && isinf(expected) && x == expected));
- if (ret){
- printf("error in test__extendhfsf2(%f) = %.20Lf, "
- "expected %.20Lf\n", a, x, expected);
- }
- return ret;
+int test_extendhfxf2(_Float16 a, long double expected) {
+ long double x = __extendhfxf2(a);
+ int ret = !(x == expected || (isnan(x) && isnan(expected)) ||
+ (isinf(x) && isinf(expected) && x == expected));
+ if (ret) {
+ printf("error in test__extendhfsf2(%f) = %.20Lf, "
+ "expected %.20Lf\n",
+ a, x, expected);
+ }
+ return ret;
}
char assumption_1[sizeof(_Float16) * CHAR_BIT == 16] = {0};
int main() {
- // Small positive value
- if (test_extendhfxf2(0.09997558593750000000f, 0.09997558593750000000f))
- return 1;
+ // Small positive value
+ if (test_extendhfxf2(0.09997558593750000000f, 0.09997558593750000000f))
+ return 1;
- // Small negative value
- if (test_extendhfxf2(-0.09997558593750000000f, -0.09997558593750000000f))
- return 1;
+ // Small negative value
+ if (test_extendhfxf2(-0.09997558593750000000f, -0.09997558593750000000f))
+ return 1;
- // Zero
- if (test_extendhfxf2(0.0f, 0.0L))
- return 1;
+ // Zero
+ if (test_extendhfxf2(0.0f, 0.0L))
+ return 1;
- // Smallest positive non-zero value
- if (test_extendhfxf2(0x1p-16f, 0x1p-16f))
- return 1;
+ // Smallest positive non-zero value
+ if (test_extendhfxf2(0x1p-16f, 0x1p-16f))
+ return 1;
- // Smallest negative non-zero value
- if (test_extendhfxf2(-0x1p-16f, -0x1p-16f))
- return 1;
+ // Smallest negative non-zero value
+ if (test_extendhfxf2(-0x1p-16f, -0x1p-16f))
+ return 1;
- // Positive infinity
- if (test_extendhfxf2(__builtin_huge_valf16(), __builtin_huge_valf64x()))
- return 1;
+ // Positive infinity
+ if (test_extendhfxf2(__builtin_huge_valf16(), __builtin_huge_valf64x()))
+ return 1;
- // Negative infinity
- if (test_extendhfxf2(-__builtin_huge_valf16(), (long double)-__builtin_huge_valf64x()))
- return 1;
+ // Negative infinity
+ if (test_extendhfxf2(-__builtin_huge_valf16(),
+ (long double)-__builtin_huge_valf64x()))
+ return 1;
- // NaN
- if (test_extendhfxf2(__builtin_nanf16(""), (long double)__builtin_nanf64x("")))
- return 1;
+ // NaN
+ if (test_extendhfxf2(__builtin_nanf16(""),
+ (long double)__builtin_nanf64x("")))
+ return 1;
- return 0;
+ return 0;
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/109090
More information about the llvm-commits
mailing list