106 changes: 104 additions & 2 deletions libc/src/math/generic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1894,6 +1894,19 @@ add_entrypoint_object(
-O2
)

add_entrypoint_object(
fmaximumf16
SRCS
fmaximumf16.cpp
HDRS
../fmaximumf16.h
DEPENDS
libc.src.__support.macros.properties.types
libc.src.__support.FPUtil.basic_operations
COMPILE_OPTIONS
-O3
)

add_entrypoint_object(
fmaximumf128
SRCS
Expand Down Expand Up @@ -1943,6 +1956,19 @@ add_entrypoint_object(
-O2
)

add_entrypoint_object(
fmaximum_numf16
SRCS
fmaximum_numf16.cpp
HDRS
../fmaximum_numf16.h
DEPENDS
libc.src.__support.macros.properties.types
libc.src.__support.FPUtil.basic_operations
COMPILE_OPTIONS
-O3
)

add_entrypoint_object(
fmaximum_numf128
SRCS
Expand Down Expand Up @@ -1992,6 +2018,19 @@ add_entrypoint_object(
-O2
)

add_entrypoint_object(
fmaximum_magf16
SRCS
fmaximum_magf16.cpp
HDRS
../fmaximum_magf16.h
DEPENDS
libc.src.__support.macros.properties.types
libc.src.__support.FPUtil.basic_operations
COMPILE_OPTIONS
-O3
)

add_entrypoint_object(
fmaximum_magf128
SRCS
Expand All @@ -2005,7 +2044,6 @@ add_entrypoint_object(
-O3
)


add_entrypoint_object(
fmaximum_mag_num
SRCS
Expand Down Expand Up @@ -2042,6 +2080,19 @@ add_entrypoint_object(
-O2
)

add_entrypoint_object(
fmaximum_mag_numf16
SRCS
fmaximum_mag_numf16.cpp
HDRS
../fmaximum_mag_numf16.h
DEPENDS
libc.src.__support.macros.properties.types
libc.src.__support.FPUtil.basic_operations
COMPILE_OPTIONS
-O3
)

add_entrypoint_object(
fmaximum_mag_numf128
SRCS
Expand Down Expand Up @@ -2091,6 +2142,19 @@ add_entrypoint_object(
-O2
)

add_entrypoint_object(
fminimumf16
SRCS
fminimumf16.cpp
HDRS
../fminimumf16.h
DEPENDS
libc.src.__support.macros.properties.types
libc.src.__support.FPUtil.basic_operations
COMPILE_OPTIONS
-O3
)

add_entrypoint_object(
fminimumf128
SRCS
Expand Down Expand Up @@ -2140,6 +2204,19 @@ add_entrypoint_object(
-O2
)

add_entrypoint_object(
fminimum_numf16
SRCS
fminimum_numf16.cpp
HDRS
../fminimum_numf16.h
DEPENDS
libc.src.__support.macros.properties.types
libc.src.__support.FPUtil.basic_operations
COMPILE_OPTIONS
-O3
)

add_entrypoint_object(
fminimum_numf128
SRCS
Expand Down Expand Up @@ -2189,6 +2266,19 @@ add_entrypoint_object(
-O2
)

add_entrypoint_object(
fminimum_magf16
SRCS
fminimum_magf16.cpp
HDRS
../fminimum_magf16.h
DEPENDS
libc.src.__support.macros.properties.types
libc.src.__support.FPUtil.basic_operations
COMPILE_OPTIONS
-O3
)

add_entrypoint_object(
fminimum_magf128
SRCS
Expand All @@ -2202,7 +2292,6 @@ add_entrypoint_object(
-O3
)


add_entrypoint_object(
fminimum_mag_num
SRCS
Expand Down Expand Up @@ -2239,6 +2328,19 @@ add_entrypoint_object(
-O2
)

add_entrypoint_object(
fminimum_mag_numf16
SRCS
fminimum_mag_numf16.cpp
HDRS
../fminimum_mag_numf16.h
DEPENDS
libc.src.__support.macros.properties.types
libc.src.__support.FPUtil.basic_operations
COMPILE_OPTIONS
-O3
)

add_entrypoint_object(
fminimum_mag_numf128
SRCS
Expand Down
19 changes: 19 additions & 0 deletions libc/src/math/generic/fmaximum_mag_numf16.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//===-- Implementation of fmaximum_mag_numf16 function --------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "src/math/fmaximum_mag_numf16.h"
#include "src/__support/FPUtil/BasicOperations.h"
#include "src/__support/common.h"

namespace LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(float16, fmaximum_mag_numf16, (float16 x, float16 y)) {
return fputil::fmaximum_mag_num(x, y);
}

} // namespace LIBC_NAMESPACE
19 changes: 19 additions & 0 deletions libc/src/math/generic/fmaximum_magf16.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//===-- Implementation of fmaximum_magf16 function ------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "src/math/fmaximum_magf16.h"
#include "src/__support/FPUtil/BasicOperations.h"
#include "src/__support/common.h"

namespace LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(float16, fmaximum_magf16, (float16 x, float16 y)) {
return fputil::fmaximum_mag(x, y);
}

} // namespace LIBC_NAMESPACE
19 changes: 19 additions & 0 deletions libc/src/math/generic/fmaximum_numf16.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//===-- Implementation of fmaximum_numf16 function ------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "src/math/fmaximum_numf16.h"
#include "src/__support/FPUtil/BasicOperations.h"
#include "src/__support/common.h"

namespace LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(float16, fmaximum_numf16, (float16 x, float16 y)) {
return fputil::fmaximum_num(x, y);
}

} // namespace LIBC_NAMESPACE
19 changes: 19 additions & 0 deletions libc/src/math/generic/fmaximumf16.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//===-- Implementation of fmaximumf16 function ----------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "src/math/fmaximumf16.h"
#include "src/__support/FPUtil/BasicOperations.h"
#include "src/__support/common.h"

namespace LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(float16, fmaximumf16, (float16 x, float16 y)) {
return fputil::fmaximum(x, y);
}

} // namespace LIBC_NAMESPACE
19 changes: 19 additions & 0 deletions libc/src/math/generic/fminimum_mag_numf16.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//===-- Implementation of fminimum_mag_numf16 function --------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "src/math/fminimum_mag_numf16.h"
#include "src/__support/FPUtil/BasicOperations.h"
#include "src/__support/common.h"

namespace LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(float16, fminimum_mag_numf16, (float16 x, float16 y)) {
return fputil::fminimum_mag_num(x, y);
}

} // namespace LIBC_NAMESPACE
19 changes: 19 additions & 0 deletions libc/src/math/generic/fminimum_magf16.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//===-- Implementation of fminimum_magf16 function ------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "src/math/fminimum_magf16.h"
#include "src/__support/FPUtil/BasicOperations.h"
#include "src/__support/common.h"

namespace LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(float16, fminimum_magf16, (float16 x, float16 y)) {
return fputil::fminimum_mag(x, y);
}

} // namespace LIBC_NAMESPACE
19 changes: 19 additions & 0 deletions libc/src/math/generic/fminimum_numf16.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//===-- Implementation of fminimum_numf16 function ------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "src/math/fminimum_numf16.h"
#include "src/__support/FPUtil/BasicOperations.h"
#include "src/__support/common.h"

namespace LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(float16, fminimum_numf16, (float16 x, float16 y)) {
return fputil::fminimum_num(x, y);
}

} // namespace LIBC_NAMESPACE
19 changes: 19 additions & 0 deletions libc/src/math/generic/fminimumf16.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//===-- Implementation of fminimumf16 function ----------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "src/math/fminimumf16.h"
#include "src/__support/FPUtil/BasicOperations.h"
#include "src/__support/common.h"

namespace LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(float16, fminimumf16, (float16 x, float16 y)) {
return fputil::fminimum(x, y);
}

} // namespace LIBC_NAMESPACE
151 changes: 149 additions & 2 deletions libc/test/src/math/smoke/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1845,6 +1845,21 @@ add_fp_unittest(
FMaximumTest.h
DEPENDS
libc.src.math.fmaximuml
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

add_fp_unittest(
fmaximumf16_test
SUITE
libc-math-smoke-tests
SRCS
fmaximumf16_test.cpp
HDRS
FMaximumTest.h
DEPENDS
libc.src.math.fmaximumf16
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -1858,6 +1873,7 @@ add_fp_unittest(
FMaximumTest.h
DEPENDS
libc.src.math.fmaximumf128
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -1871,6 +1887,7 @@ add_fp_unittest(
FMaximumTest.h
DEPENDS
libc.src.math.fmaximum
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -1884,6 +1901,7 @@ add_fp_unittest(
FMaximumTest.h
DEPENDS
libc.src.math.fmaximumf
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -1897,6 +1915,7 @@ add_fp_unittest(
FMaximumNumTest.h
DEPENDS
libc.src.math.fmaximum_numf
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -1910,6 +1929,7 @@ add_fp_unittest(
FMaximumNumTest.h
DEPENDS
libc.src.math.fmaximum_num
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -1923,6 +1943,21 @@ add_fp_unittest(
FMaximumNumTest.h
DEPENDS
libc.src.math.fmaximum_numl
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

add_fp_unittest(
fmaximum_numf16_test
SUITE
libc-math-smoke-tests
SRCS
fmaximum_numf16_test.cpp
HDRS
FMaximumNumTest.h
DEPENDS
libc.src.math.fmaximum_numf16
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -1936,6 +1971,7 @@ add_fp_unittest(
FMaximumNumTest.h
DEPENDS
libc.src.math.fmaximum_numf128
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -1949,6 +1985,8 @@ add_fp_unittest(
FMaximumMagTest.h
DEPENDS
libc.src.math.fmaximum_magf
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.basic_operations
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -1962,6 +2000,8 @@ add_fp_unittest(
FMaximumMagTest.h
DEPENDS
libc.src.math.fmaximum_mag
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.basic_operations
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -1975,6 +2015,23 @@ add_fp_unittest(
FMaximumMagTest.h
DEPENDS
libc.src.math.fmaximum_magl
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.basic_operations
libc.src.__support.FPUtil.fp_bits
)

add_fp_unittest(
fmaximum_magf16_test
SUITE
libc-math-smoke-tests
SRCS
fmaximum_magf16_test.cpp
HDRS
FMaximumMagTest.h
DEPENDS
libc.src.math.fmaximum_magf16
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.basic_operations
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -1988,10 +2045,11 @@ add_fp_unittest(
FMaximumMagTest.h
DEPENDS
libc.src.math.fmaximum_magf128
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.basic_operations
libc.src.__support.FPUtil.fp_bits
)


add_fp_unittest(
fmaximum_mag_numf_test
SUITE
Expand All @@ -2002,6 +2060,7 @@ add_fp_unittest(
FMaximumMagNumTest.h
DEPENDS
libc.src.math.fmaximum_mag_numf
libc.src.__support.FPUtil.basic_operations
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -2015,6 +2074,7 @@ add_fp_unittest(
FMaximumMagNumTest.h
DEPENDS
libc.src.math.fmaximum_mag_num
libc.src.__support.FPUtil.basic_operations
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -2028,6 +2088,21 @@ add_fp_unittest(
FMaximumMagNumTest.h
DEPENDS
libc.src.math.fmaximum_mag_numl
libc.src.__support.FPUtil.basic_operations
libc.src.__support.FPUtil.fp_bits
)

add_fp_unittest(
fmaximum_mag_numf16_test
SUITE
libc-math-smoke-tests
SRCS
fmaximum_mag_numf16_test.cpp
HDRS
FMaximumMagNumTest.h
DEPENDS
libc.src.math.fmaximum_mag_numf16
libc.src.__support.FPUtil.basic_operations
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -2041,6 +2116,7 @@ add_fp_unittest(
FMaximumMagNumTest.h
DEPENDS
libc.src.math.fmaximum_mag_numf128
libc.src.__support.FPUtil.basic_operations
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -2054,6 +2130,21 @@ add_fp_unittest(
FMinimumTest.h
DEPENDS
libc.src.math.fminimuml
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

add_fp_unittest(
fminimumf16_test
SUITE
libc-math-smoke-tests
SRCS
fminimumf16_test.cpp
HDRS
FMinimumTest.h
DEPENDS
libc.src.math.fminimumf16
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -2067,6 +2158,7 @@ add_fp_unittest(
FMinimumTest.h
DEPENDS
libc.src.math.fminimumf128
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -2080,6 +2172,7 @@ add_fp_unittest(
FMinimumTest.h
DEPENDS
libc.src.math.fminimum
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -2093,6 +2186,7 @@ add_fp_unittest(
FMinimumTest.h
DEPENDS
libc.src.math.fminimumf
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -2106,6 +2200,7 @@ add_fp_unittest(
FMinimumNumTest.h
DEPENDS
libc.src.math.fminimum_numf
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -2119,6 +2214,7 @@ add_fp_unittest(
FMinimumNumTest.h
DEPENDS
libc.src.math.fminimum_num
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -2132,6 +2228,21 @@ add_fp_unittest(
FMinimumNumTest.h
DEPENDS
libc.src.math.fminimum_numl
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

add_fp_unittest(
fminimum_numf16_test
SUITE
libc-math-smoke-tests
SRCS
fminimum_numf16_test.cpp
HDRS
FMinimumNumTest.h
DEPENDS
libc.src.math.fminimum_numf16
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -2145,6 +2256,7 @@ add_fp_unittest(
FMinimumNumTest.h
DEPENDS
libc.src.math.fminimum_numf128
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -2158,6 +2270,7 @@ add_fp_unittest(
FMinimumMagTest.h
DEPENDS
libc.src.math.fminimum_magf
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -2171,6 +2284,7 @@ add_fp_unittest(
FMinimumMagTest.h
DEPENDS
libc.src.math.fminimum_mag
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -2184,6 +2298,21 @@ add_fp_unittest(
FMinimumMagTest.h
DEPENDS
libc.src.math.fminimum_magl
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

add_fp_unittest(
fminimum_magf16_test
SUITE
libc-math-smoke-tests
SRCS
fminimum_magf16_test.cpp
HDRS
FMinimumMagTest.h
DEPENDS
libc.src.math.fminimum_magf16
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -2197,10 +2326,10 @@ add_fp_unittest(
FMinimumMagTest.h
DEPENDS
libc.src.math.fminimum_magf128
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)


add_fp_unittest(
fminimum_mag_numf_test
SUITE
Expand All @@ -2211,6 +2340,7 @@ add_fp_unittest(
FMinimumMagNumTest.h
DEPENDS
libc.src.math.fminimum_mag_numf
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -2224,6 +2354,7 @@ add_fp_unittest(
FMinimumMagNumTest.h
DEPENDS
libc.src.math.fminimum_mag_num
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -2237,6 +2368,21 @@ add_fp_unittest(
FMinimumMagNumTest.h
DEPENDS
libc.src.math.fminimum_mag_numl
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

add_fp_unittest(
fminimum_mag_numf16_test
SUITE
libc-math-smoke-tests
SRCS
fminimum_mag_numf16_test.cpp
HDRS
FMinimumMagNumTest.h
DEPENDS
libc.src.math.fminimum_mag_numf16
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -2250,6 +2396,7 @@ add_fp_unittest(
FMinimumMagNumTest.h
DEPENDS
libc.src.math.fminimum_mag_numf128
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

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

#include "src/__support/CPP/algorithm.h"
#include "src/__support/FPUtil/BasicOperations.h"
#include "src/__support/FPUtil/FPBits.h"
#include "test/UnitTest/FEnvSafeTest.h"
Expand Down Expand Up @@ -68,10 +69,11 @@ class FMaximumMagNumTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
}

void testRange(FMaximumMagNumFunc 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 All @@ -82,11 +84,10 @@ class FMaximumMagNumTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
if ((x == 0) && (y == 0))
continue;

if (LIBC_NAMESPACE::fputil::abs(x) > LIBC_NAMESPACE::fputil::abs(y)) {
if (LIBC_NAMESPACE::fputil::abs(x) > LIBC_NAMESPACE::fputil::abs(y))
EXPECT_FP_EQ(x, func(x, y));
} else {
else
EXPECT_FP_EQ(y, func(x, y));
}
}
}
};
Expand Down
15 changes: 8 additions & 7 deletions libc/test/src/math/smoke/FMaximumMagTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#ifndef LLVM_LIBC_TEST_SRC_MATH_SMOKE_FMAXIMUM_MAGTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_SMOKE_FMAXIMUM_MAGTEST_H

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

void testRange(FMaximumMagFunc 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 All @@ -70,11 +72,10 @@ class FMaximumMagTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
if ((x == 0) && (y == 0))
continue;

if (LIBC_NAMESPACE::fputil::abs(x) > LIBC_NAMESPACE::fputil::abs(y)) {
if (LIBC_NAMESPACE::fputil::abs(x) > LIBC_NAMESPACE::fputil::abs(y))
EXPECT_FP_EQ(x, func(x, y));
} else {
else
EXPECT_FP_EQ(y, func(x, y));
}
}
}
};
Expand Down
15 changes: 8 additions & 7 deletions libc/test/src/math/smoke/FMaximumNumTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#ifndef LLVM_LIBC_TEST_SRC_MATH_SMOKE_FMAXIMUMNUMTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_SMOKE_FMAXIMUMNUMTEST_H

#include "src/__support/CPP/algorithm.h"
#include "src/__support/FPUtil/FPBits.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
Expand Down Expand Up @@ -67,10 +68,11 @@ class FMaximumNumTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
}

void testRange(FMaximumNumFunc 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 All @@ -81,11 +83,10 @@ class FMaximumNumTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
if ((x == 0) && (y == 0))
continue;

if (x > y) {
if (x > y)
EXPECT_FP_EQ(x, func(x, y));
} else {
else
EXPECT_FP_EQ(y, func(x, y));
}
}
}
};
Expand Down
15 changes: 8 additions & 7 deletions libc/test/src/math/smoke/FMaximumTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#ifndef LLVM_LIBC_TEST_SRC_MATH_SMOKE_FMAXIMUMTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_SMOKE_FMAXIMUMTEST_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 FMaximumTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
}

void testRange(FMaximumFunc 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 All @@ -69,11 +71,10 @@ class FMaximumTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
if ((x == 0) && (y == 0))
continue;

if (x > y) {
if (x > y)
EXPECT_FP_EQ(x, func(x, y));
} else {
else
EXPECT_FP_EQ(y, func(x, y));
}
}
}
};
Expand Down
15 changes: 8 additions & 7 deletions libc/test/src/math/smoke/FMinimumMagNumTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#ifndef LLVM_LIBC_TEST_SRC_MATH_SMOKE_FMINIMUMMAG_NUMTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_SMOKE_FMINIMUMMAG_NUMTEST_H

#include "src/__support/CPP/algorithm.h"
#include "src/__support/FPUtil/BasicOperations.h"
#include "src/__support/FPUtil/FPBits.h"
#include "test/UnitTest/FEnvSafeTest.h"
Expand Down Expand Up @@ -68,10 +69,11 @@ class FMinimumMagNumTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
}

void testRange(FMinimumMagNumFunc 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 All @@ -82,11 +84,10 @@ class FMinimumMagNumTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
if ((x == 0) && (y == 0))
continue;

if (LIBC_NAMESPACE::fputil::abs(x) > LIBC_NAMESPACE::fputil::abs(y)) {
if (LIBC_NAMESPACE::fputil::abs(x) > LIBC_NAMESPACE::fputil::abs(y))
EXPECT_FP_EQ(y, func(x, y));
} else {
else
EXPECT_FP_EQ(x, func(x, y));
}
}
}
};
Expand Down
15 changes: 8 additions & 7 deletions libc/test/src/math/smoke/FMinimumMagTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#ifndef LLVM_LIBC_TEST_SRC_MATH_SMOKE_FMINIMUM_MAGTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_SMOKE_FMINIMUM_MAGTEST_H

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

void testRange(FMinimumMagFunc 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 All @@ -70,11 +72,10 @@ class FMinimumMagTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
if ((x == 0) && (y == 0))
continue;

if (LIBC_NAMESPACE::fputil::abs(x) < LIBC_NAMESPACE::fputil::abs(y)) {
if (LIBC_NAMESPACE::fputil::abs(x) < LIBC_NAMESPACE::fputil::abs(y))
EXPECT_FP_EQ(x, func(x, y));
} else {
else
EXPECT_FP_EQ(y, func(x, y));
}
}
}
};
Expand Down
15 changes: 8 additions & 7 deletions libc/test/src/math/smoke/FMinimumNumTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#ifndef LLVM_LIBC_TEST_SRC_MATH_SMOKE_FMINIMUMNUMTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_SMOKE_FMINIMUMNUMTEST_H

#include "src/__support/CPP/algorithm.h"
#include "src/__support/FPUtil/FPBits.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
Expand Down Expand Up @@ -67,10 +68,11 @@ class FMinimumNumTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
}

void testRange(FMinimumNumFunc 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 All @@ -81,11 +83,10 @@ class FMinimumNumTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
if ((x == 0) && (y == 0))
continue;

if (x > y) {
if (x > y)
EXPECT_FP_EQ(y, func(x, y));
} else {
else
EXPECT_FP_EQ(x, func(x, y));
}
}
}
};
Expand Down
15 changes: 8 additions & 7 deletions libc/test/src/math/smoke/FMinimumTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#ifndef LLVM_LIBC_TEST_SRC_MATH_SMOKE_FMINIMUMTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_SMOKE_FMINIMUMTEST_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 FMinimumTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
}

void testRange(FMinimumFunc 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 All @@ -69,11 +71,10 @@ class FMinimumTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
if ((x == 0) && (y == 0))
continue;

if (x > y) {
if (x > y)
EXPECT_FP_EQ(y, func(x, y));
} else {
else
EXPECT_FP_EQ(x, func(x, y));
}
}
}
};
Expand Down
13 changes: 13 additions & 0 deletions libc/test/src/math/smoke/fmaximum_mag_numf16_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//===-- Unittests for fmaximum_mag_numf16 ---------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "FMaximumMagNumTest.h"

#include "src/math/fmaximum_mag_numf16.h"

LIST_FMAXIMUM_MAG_NUM_TESTS(float16, LIBC_NAMESPACE::fmaximum_mag_numf16)
13 changes: 13 additions & 0 deletions libc/test/src/math/smoke/fmaximum_magf16_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//===-- Unittests for fmaximum_magf16 -------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "FMaximumMagTest.h"

#include "src/math/fmaximum_magf16.h"

LIST_FMAXIMUM_MAG_TESTS(float16, LIBC_NAMESPACE::fmaximum_magf16)
13 changes: 13 additions & 0 deletions libc/test/src/math/smoke/fmaximum_numf16_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//===-- Unittests for fmaximum_numf16 -------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "FMaximumNumTest.h"

#include "src/math/fmaximum_numf16.h"

LIST_FMAXIMUM_NUM_TESTS(float16, LIBC_NAMESPACE::fmaximum_numf16)
13 changes: 13 additions & 0 deletions libc/test/src/math/smoke/fmaximumf16_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//===-- Unittests for fmaximumf16 -----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "FMaximumTest.h"

#include "src/math/fmaximumf16.h"

LIST_FMAXIMUM_TESTS(float16, LIBC_NAMESPACE::fmaximumf16)
13 changes: 13 additions & 0 deletions libc/test/src/math/smoke/fminimum_mag_numf16_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//===-- Unittests for fminimum_mag_numf16 ---------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "FMinimumMagNumTest.h"

#include "src/math/fminimum_mag_numf16.h"

LIST_FMINIMUM_MAG_NUM_TESTS(float16, LIBC_NAMESPACE::fminimum_mag_numf16)
13 changes: 13 additions & 0 deletions libc/test/src/math/smoke/fminimum_magf16_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//===-- Unittests for fminimum_magf16 -------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "FMinimumMagTest.h"

#include "src/math/fminimum_magf16.h"

LIST_FMINIMUM_MAG_TESTS(float16, LIBC_NAMESPACE::fminimum_magf16)
13 changes: 13 additions & 0 deletions libc/test/src/math/smoke/fminimum_numf16_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//===-- Unittests for fminimum_numf16 -------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "FMinimumNumTest.h"

#include "src/math/fminimum_numf16.h"

LIST_FMINIMUM_NUM_TESTS(float16, LIBC_NAMESPACE::fminimum_numf16)
13 changes: 13 additions & 0 deletions libc/test/src/math/smoke/fminimumf16_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//===-- Unittests for fminimumf16 -----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "FMinimumTest.h"

#include "src/math/fminimumf16.h"

LIST_FMINIMUM_TESTS(float16, LIBC_NAMESPACE::fminimumf16)