Skip to content

Commit cbe97e9

Browse files
authored
Revert "[libc][math][c23] Add MPFR unit tests for {ceil,floor,round,roundeven,trunc}f16 (#94383)" (#94505)
This reverts commit fda1e4b. The commit caused Buildbot failures: - https://lab.llvm.org/buildbot/#/builders/256/builds/14331 - https://lab.llvm.org/buildbot/#/builders/229/builds/27009
1 parent 8407779 commit cbe97e9

12 files changed

+53
-264
lines changed

libc/test/src/math/CMakeLists.txt

-90
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ add_fp_unittest(
141141
TruncTest.h
142142
DEPENDS
143143
libc.src.math.trunc
144-
libc.src.__support.CPP.algorithm
145144
libc.src.__support.FPUtil.fp_bits
146145
)
147146

@@ -156,7 +155,6 @@ add_fp_unittest(
156155
TruncTest.h
157156
DEPENDS
158157
libc.src.math.truncf
159-
libc.src.__support.CPP.algorithm
160158
libc.src.__support.FPUtil.fp_bits
161159
)
162160

@@ -171,22 +169,6 @@ add_fp_unittest(
171169
TruncTest.h
172170
DEPENDS
173171
libc.src.math.truncl
174-
libc.src.__support.CPP.algorithm
175-
libc.src.__support.FPUtil.fp_bits
176-
)
177-
178-
add_fp_unittest(
179-
truncf16_test
180-
NEED_MPFR
181-
SUITE
182-
libc-math-unittests
183-
SRCS
184-
truncf16_test.cpp
185-
HDRS
186-
TruncTest.h
187-
DEPENDS
188-
libc.src.math.truncf16
189-
libc.src.__support.CPP.algorithm
190172
libc.src.__support.FPUtil.fp_bits
191173
)
192174

@@ -201,7 +183,6 @@ add_fp_unittest(
201183
CeilTest.h
202184
DEPENDS
203185
libc.src.math.ceil
204-
libc.src.__support.CPP.algorithm
205186
libc.src.__support.FPUtil.fp_bits
206187
)
207188

@@ -216,7 +197,6 @@ add_fp_unittest(
216197
CeilTest.h
217198
DEPENDS
218199
libc.src.math.ceilf
219-
libc.src.__support.CPP.algorithm
220200
libc.src.__support.FPUtil.fp_bits
221201
)
222202

@@ -231,22 +211,6 @@ add_fp_unittest(
231211
CeilTest.h
232212
DEPENDS
233213
libc.src.math.ceill
234-
libc.src.__support.CPP.algorithm
235-
libc.src.__support.FPUtil.fp_bits
236-
)
237-
238-
add_fp_unittest(
239-
ceilf16_test
240-
NEED_MPFR
241-
SUITE
242-
libc-math-unittests
243-
SRCS
244-
ceilf16_test.cpp
245-
HDRS
246-
CeilTest.h
247-
DEPENDS
248-
libc.src.math.ceilf16
249-
libc.src.__support.CPP.algorithm
250214
libc.src.__support.FPUtil.fp_bits
251215
)
252216

@@ -261,7 +225,6 @@ add_fp_unittest(
261225
FloorTest.h
262226
DEPENDS
263227
libc.src.math.floor
264-
libc.src.__support.CPP.algorithm
265228
libc.src.__support.FPUtil.fp_bits
266229
)
267230

@@ -276,7 +239,6 @@ add_fp_unittest(
276239
FloorTest.h
277240
DEPENDS
278241
libc.src.math.floorf
279-
libc.src.__support.CPP.algorithm
280242
libc.src.__support.FPUtil.fp_bits
281243
)
282244

@@ -291,22 +253,6 @@ add_fp_unittest(
291253
FloorTest.h
292254
DEPENDS
293255
libc.src.math.floorl
294-
libc.src.__support.CPP.algorithm
295-
libc.src.__support.FPUtil.fp_bits
296-
)
297-
298-
add_fp_unittest(
299-
floorf16_test
300-
NEED_MPFR
301-
SUITE
302-
libc-math-unittests
303-
SRCS
304-
floorf16_test.cpp
305-
HDRS
306-
FloorTest.h
307-
DEPENDS
308-
libc.src.math.floorf16
309-
libc.src.__support.CPP.algorithm
310256
libc.src.__support.FPUtil.fp_bits
311257
)
312258

@@ -321,7 +267,6 @@ add_fp_unittest(
321267
RoundTest.h
322268
DEPENDS
323269
libc.src.math.round
324-
libc.src.__support.CPP.algorithm
325270
libc.src.__support.FPUtil.fp_bits
326271
)
327272

@@ -336,7 +281,6 @@ add_fp_unittest(
336281
RoundTest.h
337282
DEPENDS
338283
libc.src.math.roundf
339-
libc.src.__support.CPP.algorithm
340284
libc.src.__support.FPUtil.fp_bits
341285
)
342286

@@ -351,22 +295,6 @@ add_fp_unittest(
351295
RoundTest.h
352296
DEPENDS
353297
libc.src.math.roundl
354-
libc.src.__support.CPP.algorithm
355-
libc.src.__support.FPUtil.fp_bits
356-
)
357-
358-
add_fp_unittest(
359-
roundf16_test
360-
NEED_MPFR
361-
SUITE
362-
libc-math-unittests
363-
SRCS
364-
roundf16_test.cpp
365-
HDRS
366-
RoundTest.h
367-
DEPENDS
368-
libc.src.math.roundf16
369-
libc.src.__support.CPP.algorithm
370298
libc.src.__support.FPUtil.fp_bits
371299
)
372300

@@ -381,7 +309,6 @@ add_fp_unittest(
381309
RoundEvenTest.h
382310
DEPENDS
383311
libc.src.math.roundeven
384-
libc.src.__support.CPP.algorithm
385312
libc.src.__support.FPUtil.fp_bits
386313
)
387314

@@ -396,7 +323,6 @@ add_fp_unittest(
396323
RoundEvenTest.h
397324
DEPENDS
398325
libc.src.math.roundevenf
399-
libc.src.__support.CPP.algorithm
400326
libc.src.__support.FPUtil.fp_bits
401327
)
402328

@@ -411,22 +337,6 @@ add_fp_unittest(
411337
RoundEvenTest.h
412338
DEPENDS
413339
libc.src.math.roundevenl
414-
libc.src.__support.CPP.algorithm
415-
libc.src.__support.FPUtil.fp_bits
416-
)
417-
418-
add_fp_unittest(
419-
roundevenf16_test
420-
NEED_MPFR
421-
SUITE
422-
libc-math-unittests
423-
SRCS
424-
roundevenf16_test.cpp
425-
HDRS
426-
RoundEvenTest.h
427-
DEPENDS
428-
libc.src.math.roundevenf16
429-
libc.src.__support.CPP.algorithm
430340
libc.src.__support.FPUtil.fp_bits
431341
)
432342

libc/test/src/math/CeilTest.h

+9-18
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#ifndef LLVM_LIBC_TEST_SRC_MATH_CEILTEST_H
10-
#define LLVM_LIBC_TEST_SRC_MATH_CEILTEST_H
11-
12-
#include "src/__support/CPP/algorithm.h"
139
#include "test/UnitTest/FEnvSafeTest.h"
1410
#include "test/UnitTest/FPMatcher.h"
1511
#include "test/UnitTest/Test.h"
@@ -63,21 +59,18 @@ class CeilTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
6359
EXPECT_FP_EQ(T(-10.0), func(T(-10.32)));
6460
EXPECT_FP_EQ(T(11.0), func(T(10.65)));
6561
EXPECT_FP_EQ(T(-10.0), func(T(-10.65)));
66-
EXPECT_FP_EQ(T(124.0), func(T(123.38)));
67-
EXPECT_FP_EQ(T(-123.0), func(T(-123.38)));
68-
EXPECT_FP_EQ(T(124.0), func(T(123.96)));
69-
EXPECT_FP_EQ(T(-123.0), func(T(-123.96)));
62+
EXPECT_FP_EQ(T(1235.0), func(T(1234.38)));
63+
EXPECT_FP_EQ(T(-1234.0), func(T(-1234.38)));
64+
EXPECT_FP_EQ(T(1235.0), func(T(1234.96)));
65+
EXPECT_FP_EQ(T(-1234.0), func(T(-1234.96)));
7066
}
7167

7268
void testRange(CeilFunc func) {
73-
constexpr int COUNT = 100'000;
74-
constexpr StorageType STEP = LIBC_NAMESPACE::cpp::max(
75-
static_cast<StorageType>(STORAGE_MAX / COUNT), StorageType(1));
76-
StorageType v = 0;
77-
for (int i = 0; i <= COUNT; ++i, v += STEP) {
78-
FPBits xbits(v);
79-
T x = xbits.get_val();
80-
if (xbits.is_inf_or_nan())
69+
constexpr StorageType COUNT = 100'000;
70+
constexpr StorageType STEP = STORAGE_MAX / COUNT;
71+
for (StorageType i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
72+
T x = FPBits(v).get_val();
73+
if (isnan(x) || isinf(x))
8174
continue;
8275

8376
ASSERT_MPFR_MATCH(mpfr::Operation::Ceil, x, func(x), 0.0);
@@ -91,5 +84,3 @@ class CeilTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
9184
TEST_F(LlvmLibcCeilTest, RoundedNubmers) { testRoundedNumbers(&func); } \
9285
TEST_F(LlvmLibcCeilTest, Fractions) { testFractions(&func); } \
9386
TEST_F(LlvmLibcCeilTest, Range) { testRange(&func); }
94-
95-
#endif // LLVM_LIBC_TEST_SRC_MATH_CEILTEST_H

libc/test/src/math/FloorTest.h

+9-13
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#ifndef LLVM_LIBC_TEST_SRC_MATH_FLOORTEST_H
1010
#define LLVM_LIBC_TEST_SRC_MATH_FLOORTEST_H
1111

12-
#include "src/__support/CPP/algorithm.h"
1312
#include "test/UnitTest/FEnvSafeTest.h"
1413
#include "test/UnitTest/FPMatcher.h"
1514
#include "test/UnitTest/Test.h"
@@ -63,21 +62,18 @@ class FloorTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
6362
EXPECT_FP_EQ(T(-11.0), func(T(-10.32)));
6463
EXPECT_FP_EQ(T(10.0), func(T(10.65)));
6564
EXPECT_FP_EQ(T(-11.0), func(T(-10.65)));
66-
EXPECT_FP_EQ(T(123.0), func(T(123.38)));
67-
EXPECT_FP_EQ(T(-124.0), func(T(-123.38)));
68-
EXPECT_FP_EQ(T(123.0), func(T(123.96)));
69-
EXPECT_FP_EQ(T(-124.0), func(T(-123.96)));
65+
EXPECT_FP_EQ(T(1234.0), func(T(1234.38)));
66+
EXPECT_FP_EQ(T(-1235.0), func(T(-1234.38)));
67+
EXPECT_FP_EQ(T(1234.0), func(T(1234.96)));
68+
EXPECT_FP_EQ(T(-1235.0), func(T(-1234.96)));
7069
}
7170

7271
void testRange(FloorFunc func) {
73-
constexpr int COUNT = 100'000;
74-
constexpr StorageType STEP = LIBC_NAMESPACE::cpp::max(
75-
static_cast<StorageType>(STORAGE_MAX / COUNT), StorageType(1));
76-
StorageType v = 0;
77-
for (int i = 0; i <= COUNT; ++i, v += STEP) {
78-
FPBits xbits(v);
79-
T x = xbits.get_val();
80-
if (xbits.is_inf_or_nan())
72+
constexpr StorageType COUNT = 100'000;
73+
constexpr StorageType STEP = STORAGE_MAX / COUNT;
74+
for (StorageType i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
75+
T x = FPBits(v).get_val();
76+
if (isnan(x) || isinf(x))
8177
continue;
8278

8379
ASSERT_MPFR_MATCH(mpfr::Operation::Floor, x, func(x), 0.0);

libc/test/src/math/RoundEvenTest.h

+13-17
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#ifndef LLVM_LIBC_TEST_SRC_MATH_ROUNDEVENTEST_H
1010
#define LLVM_LIBC_TEST_SRC_MATH_ROUNDEVENTEST_H
1111

12-
#include "src/__support/CPP/algorithm.h"
1312
#include "test/UnitTest/FEnvSafeTest.h"
1413
#include "test/UnitTest/FPMatcher.h"
1514
#include "test/UnitTest/Test.h"
@@ -61,25 +60,22 @@ class RoundEvenTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
6160
EXPECT_FP_EQ(T(-2.0), func(T(-1.75)));
6261
EXPECT_FP_EQ(T(11.0), func(T(10.65)));
6362
EXPECT_FP_EQ(T(-11.0), func(T(-10.65)));
64-
EXPECT_FP_EQ(T(123.0), func(T(123.25)));
65-
EXPECT_FP_EQ(T(124.0), func(T(123.50)));
66-
EXPECT_FP_EQ(T(124.0), func(T(123.75)));
67-
EXPECT_FP_EQ(T(-123.0), func(T(-123.25)));
68-
EXPECT_FP_EQ(T(-124.0), func(T(-123.50)));
69-
EXPECT_FP_EQ(T(-124.0), func(T(-123.75)));
70-
EXPECT_FP_EQ(T(124.0), func(T(124.50)));
71-
EXPECT_FP_EQ(T(-124.0), func(T(-124.50)));
63+
EXPECT_FP_EQ(T(1233.0), func(T(1233.25)));
64+
EXPECT_FP_EQ(T(1234.0), func(T(1233.50)));
65+
EXPECT_FP_EQ(T(1234.0), func(T(1233.75)));
66+
EXPECT_FP_EQ(T(-1233.0), func(T(-1233.25)));
67+
EXPECT_FP_EQ(T(-1234.0), func(T(-1233.50)));
68+
EXPECT_FP_EQ(T(-1234.0), func(T(-1233.75)));
69+
EXPECT_FP_EQ(T(1234.0), func(T(1234.50)));
70+
EXPECT_FP_EQ(T(-1234.0), func(T(-1234.50)));
7271
}
7372

7473
void testRange(RoundEvenFunc func) {
75-
constexpr int COUNT = 100'000;
76-
constexpr StorageType STEP = LIBC_NAMESPACE::cpp::max(
77-
static_cast<StorageType>(STORAGE_MAX / COUNT), StorageType(1));
78-
StorageType v = 0;
79-
for (int i = 0; i <= COUNT; ++i, v += STEP) {
80-
FPBits xbits(v);
81-
T x = xbits.get_val();
82-
if (xbits.is_inf_or_nan())
74+
constexpr StorageType COUNT = 100'000;
75+
constexpr StorageType STEP = STORAGE_MAX / COUNT;
76+
for (StorageType i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
77+
T x = FPBits(v).get_val();
78+
if (isnan(x) || isinf(x))
8379
continue;
8480

8581
ASSERT_MPFR_MATCH(mpfr::Operation::RoundEven, x, func(x), 0.0);

libc/test/src/math/RoundTest.h

+9-13
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#ifndef LLVM_LIBC_TEST_SRC_MATH_ROUNDTEST_H
1010
#define LLVM_LIBC_TEST_SRC_MATH_ROUNDTEST_H
1111

12-
#include "src/__support/CPP/algorithm.h"
1312
#include "test/UnitTest/FEnvSafeTest.h"
1413
#include "test/UnitTest/FPMatcher.h"
1514
#include "test/UnitTest/Test.h"
@@ -63,21 +62,18 @@ class RoundTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
6362
EXPECT_FP_EQ(T(-10.0), func(T(-10.32)));
6463
EXPECT_FP_EQ(T(11.0), func(T(10.65)));
6564
EXPECT_FP_EQ(T(-11.0), func(T(-10.65)));
66-
EXPECT_FP_EQ(T(123.0), func(T(123.38)));
67-
EXPECT_FP_EQ(T(-123.0), func(T(-123.38)));
68-
EXPECT_FP_EQ(T(124.0), func(T(123.96)));
69-
EXPECT_FP_EQ(T(-124.0), func(T(-123.96)));
65+
EXPECT_FP_EQ(T(1234.0), func(T(1234.38)));
66+
EXPECT_FP_EQ(T(-1234.0), func(T(-1234.38)));
67+
EXPECT_FP_EQ(T(1235.0), func(T(1234.96)));
68+
EXPECT_FP_EQ(T(-1235.0), func(T(-1234.96)));
7069
}
7170

7271
void testRange(RoundFunc func) {
73-
constexpr int COUNT = 100'000;
74-
constexpr StorageType STEP = LIBC_NAMESPACE::cpp::max(
75-
static_cast<StorageType>(STORAGE_MAX / COUNT), StorageType(1));
76-
StorageType v = 0;
77-
for (int i = 0; i <= COUNT; ++i, v += STEP) {
78-
FPBits xbits(v);
79-
T x = xbits.get_val();
80-
if (xbits.is_inf_or_nan())
72+
constexpr StorageType COUNT = 100'000;
73+
constexpr StorageType STEP = STORAGE_MAX / COUNT;
74+
for (StorageType i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
75+
T x = FPBits(v).get_val();
76+
if (isnan(x) || isinf(x))
8177
continue;
8278

8379
ASSERT_MPFR_MATCH(mpfr::Operation::Round, x, func(x), 0.0);

0 commit comments

Comments
 (0)