Skip to content

Commit 72506eb

Browse files
Sunday111Kostiantyn Lazukin
and
Kostiantyn Lazukin
authored
[compiler-rt] Fix addtf3_test.c being skipped due to misplaced include (llvm#134106)
[compiler-rt] The test `addtf3_test.c` is currently guarded by `#if defined(CRT_HAS_IEEE_TF)`, a macro that is declared in `int_lib.h`. However, `int_lib.h` is included *after* the preprocessor check, which results in the macro not being defined in time and causes the test to always be skipped. This patch moves the includes of `fp_test.h` and `int_lib.h` to the top of the file so that `CRT_HAS_IEEE_TF` is defined before it is checked. Co-authored-by: Kostiantyn Lazukin <koslaz01@ip-10-252-21-142.eu-west-1.compute.internal>
1 parent 726a5c2 commit 72506eb

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

compiler-rt/test/builtins/Unit/addtf3_test.c

+10-4
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
#include <fenv.h>
55
#include <stdio.h>
66

7+
#include "fp_test.h"
8+
#include "int_lib.h"
9+
710
// The testcase currently assumes IEEE TF format, once that has been
811
// fixed the defined(CRT_HAS_IEEE_TF) guard can be removed to enable it for
912
// IBM 128 floats as well.
1013
#if defined(CRT_HAS_IEEE_TF)
1114

12-
# include "fp_test.h"
13-
# include "int_lib.h"
14-
1515
// Returns: a + b
1616
COMPILER_RT_ABI tf_float __addtf3(tf_float a, tf_float b);
1717

@@ -62,7 +62,13 @@ int main() {
6262
defined(i386) || defined(__x86_64__) || \
6363
(defined(__loongarch__) && __loongarch_frlen != 0)
6464
// Rounding mode tests on supported architectures
65-
const tf_float m = 1234.0L, n = 0.01L;
65+
// Use explicit values because the binary representation of long double
66+
// is platform dependent. Intended values:
67+
// m = 1234.0L, n = 0.01L (where L is a literal for 128 bit long double)
68+
const tf_float m =
69+
fromRep128(UINT64_C(0x4009348000000000), UINT64_C(0x0000000000000000));
70+
const tf_float n =
71+
fromRep128(UINT64_C(0x3FF847AE147AE147), UINT64_C(0xAE147AE147AE147B));
6672

6773
fesetround(FE_UPWARD);
6874
if (test__addtf3(m, n, UINT64_C(0x40093480a3d70a3d),

0 commit comments

Comments
 (0)