aboutsummaryrefslogtreecommitdiff
path: root/libc/test
diff options
context:
space:
mode:
authorOverMighty <its.overmighty@gmail.com>2024-06-06 17:16:59 +0200
committerGitHub <noreply@github.com>2024-06-06 11:16:59 -0400
commit3c6d004068a8b7ff036edab6dbbba7ccc2786dae (patch)
treedc0d7f525cd3a0e57de9a966674e3a22fbd1686c /libc/test
parent5be0d00daa5737b6d2165d0c3ec29ce8af068053 (diff)
downloadllvm-3c6d004068a8b7ff036edab6dbbba7ccc2786dae.zip
llvm-3c6d004068a8b7ff036edab6dbbba7ccc2786dae.tar.gz
llvm-3c6d004068a8b7ff036edab6dbbba7ccc2786dae.tar.bz2
[libc][math][c23] Fix implicit conversion in smoke tests for {fmax,fmin}f16 (#94624)
Diffstat (limited to 'libc/test')
-rw-r--r--libc/test/src/math/smoke/CMakeLists.txt10
-rw-r--r--libc/test/src/math/smoke/FMaxTest.h10
-rw-r--r--libc/test/src/math/smoke/FMinTest.h10
3 files changed, 22 insertions, 8 deletions
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index 8919b54..16c6537 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -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
)
@@ -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
)
@@ -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
)
@@ -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
)
@@ -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
)
@@ -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
)
@@ -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
)
@@ -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
)
@@ -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
)
@@ -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
)
diff --git a/libc/test/src/math/smoke/FMaxTest.h b/libc/test/src/math/smoke/FMaxTest.h
index df8e35e..f4c78b5 100644
--- a/libc/test/src/math/smoke/FMaxTest.h
+++ b/libc/test/src/math/smoke/FMaxTest.h
@@ -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"
@@ -55,10 +56,11 @@ public:
}
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;
diff --git a/libc/test/src/math/smoke/FMinTest.h b/libc/test/src/math/smoke/FMinTest.h
index f71b558..629aaab 100644
--- a/libc/test/src/math/smoke/FMinTest.h
+++ b/libc/test/src/math/smoke/FMinTest.h
@@ -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"
@@ -55,10 +56,11 @@ public:
}
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;