Skip to content

[libc][math][c23] Fix implicit conversion in smoke tests for {fmax,fmin}f16 #94624

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions libc/test/src/math/smoke/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1705,6 +1705,7 @@ add_fp_unittest(
FMinTest.h
DEPENDS
libc.src.math.fminf
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -1718,6 +1719,7 @@ add_fp_unittest(
FMinTest.h
DEPENDS
libc.src.math.fmin
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -1731,6 +1733,7 @@ add_fp_unittest(
FMinTest.h
DEPENDS
libc.src.math.fminl
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -1744,6 +1747,7 @@ add_fp_unittest(
FMinTest.h
DEPENDS
libc.src.math.fminf128
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -1757,6 +1761,7 @@ add_fp_unittest(
FMinTest.h
DEPENDS
libc.src.math.fminf16
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -1770,6 +1775,7 @@ add_fp_unittest(
FMaxTest.h
DEPENDS
libc.src.math.fmaxf
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -1783,6 +1789,7 @@ add_fp_unittest(
FMaxTest.h
DEPENDS
libc.src.math.fmax
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -1796,6 +1803,7 @@ add_fp_unittest(
FMaxTest.h
DEPENDS
libc.src.math.fmaxl
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -1809,6 +1817,7 @@ add_fp_unittest(
FMaxTest.h
DEPENDS
libc.src.math.fmaxf128
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -1822,6 +1831,7 @@ add_fp_unittest(
FMaxTest.h
DEPENDS
libc.src.math.fmaxf16
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

Expand Down
10 changes: 6 additions & 4 deletions libc/test/src/math/smoke/FMaxTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#ifndef LLVM_LIBC_TEST_SRC_MATH_SMOKE_FMAXTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_SMOKE_FMAXTEST_H

#include "src/__support/CPP/algorithm.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
Expand Down Expand Up @@ -55,10 +56,11 @@ class FMaxTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
}

void testRange(FMaxFunc func) {
constexpr StorageType COUNT = 100'001;
constexpr StorageType STEP = STORAGE_MAX / COUNT;
for (StorageType i = 0, v = 0, w = STORAGE_MAX; i <= COUNT;
++i, v += STEP, w -= STEP) {
constexpr int COUNT = 100'001;
constexpr StorageType STEP = LIBC_NAMESPACE::cpp::max(
static_cast<StorageType>(STORAGE_MAX / COUNT), StorageType(1));
StorageType v = 0, w = STORAGE_MAX;
for (int i = 0; i <= COUNT; ++i, v += STEP, w -= STEP) {
FPBits xbits(v), ybits(w);
if (xbits.is_inf_or_nan())
continue;
Expand Down
10 changes: 6 additions & 4 deletions libc/test/src/math/smoke/FMinTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#ifndef LLVM_LIBC_TEST_SRC_MATH_SMOKE_FMINTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_SMOKE_FMINTEST_H

#include "src/__support/CPP/algorithm.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
Expand Down Expand Up @@ -55,10 +56,11 @@ class FMinTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
}

void testRange(FMinFunc func) {
constexpr StorageType COUNT = 100'001;
constexpr StorageType STEP = STORAGE_MAX / COUNT;
for (StorageType i = 0, v = 0, w = STORAGE_MAX; i <= COUNT;
++i, v += STEP, w -= STEP) {
constexpr int COUNT = 100'001;
constexpr StorageType STEP = LIBC_NAMESPACE::cpp::max(
static_cast<StorageType>(STORAGE_MAX / COUNT), StorageType(1));
StorageType v = 0, w = STORAGE_MAX;
for (int i = 0; i <= COUNT; ++i, v += STEP, w -= STEP) {
FPBits xbits(v), ybits(w);
if (xbits.is_inf_or_nan())
continue;
Expand Down
Loading