https://github.com/Sukumarsawant updated https://github.com/llvm/llvm-project/pull/217575
>From e8de1a9e3b660ab6a2b86ddc3c85d17b23fe7620 Mon Sep 17 00:00:00 2001 From: Sukumarsawant <[email protected]> Date: Thu, 20 Aug 2026 15:35:12 +0530 Subject: [PATCH 1/4] nextafterf128 --- libc/config/baremetal/aarch64/entrypoints.txt | 2 +- libc/config/baremetal/arm/entrypoints.txt | 2 +- libc/config/baremetal/riscv/entrypoints.txt | 2 +- libc/config/darwin/aarch64/entrypoints.txt | 2 +- libc/config/darwin/x86_64/entrypoints.txt | 1 + libc/config/freebsd/x86_64/entrypoints.txt | 2 +- libc/config/gpu/amdgpu/entrypoints.txt | 1 + libc/config/gpu/nvptx/entrypoints.txt | 1 + libc/config/linux/aarch64/entrypoints.txt | 2 +- libc/config/linux/arm/entrypoints.txt | 1 + libc/config/linux/riscv/entrypoints.txt | 2 +- libc/config/linux/x86_64/entrypoints.txt | 2 +- libc/config/windows/entrypoints.txt | 1 + libc/shared/math/nextafterf128.h | 6 ------ libc/src/__support/math/CMakeLists.txt | 2 +- libc/src/__support/math/nextafterf128.h | 11 ++++------- libc/src/math/generic/CMakeLists.txt | 1 + libc/src/math/generic/nextafterf128.cpp | 5 ++++- libc/src/math/nextafterf128.h | 5 +++++ libc/test/shared/shared_math_constexpr_test.cpp | 4 +--- libc/test/shared/shared_math_test.cpp | 3 +-- libc/test/src/math/CMakeLists.txt | 1 + libc/test/src/math/nextafterf128_test.cpp | 5 +++++ libc/test/src/math/smoke/CMakeLists.txt | 1 + libc/test/src/math/smoke/nextafterf128_test.cpp | 5 +++++ utils/bazel/llvm-project-overlay/libc/BUILD.bazel | 4 +++- .../libc/test/src/math/smoke/BUILD.bazel | 3 +++ 27 files changed, 48 insertions(+), 29 deletions(-) diff --git a/libc/config/baremetal/aarch64/entrypoints.txt b/libc/config/baremetal/aarch64/entrypoints.txt index 757e4729699d1..d975c783447da 100644 --- a/libc/config/baremetal/aarch64/entrypoints.txt +++ b/libc/config/baremetal/aarch64/entrypoints.txt @@ -545,6 +545,7 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.nearbyintl libc.src.math.nextafter libc.src.math.nextafterf + libc.src.math.nextafterf128 libc.src.math.nextafterl libc.src.math.nextdown libc.src.math.nextdownf @@ -784,7 +785,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128) libc.src.math.logbf128 libc.src.math.modff128 libc.src.math.nanf128 - libc.src.math.nextafterf128 libc.src.math.nextdownf128 libc.src.math.nextupf128 libc.src.math.remainderf128 diff --git a/libc/config/baremetal/arm/entrypoints.txt b/libc/config/baremetal/arm/entrypoints.txt index 13d4f777650f7..751162df15496 100644 --- a/libc/config/baremetal/arm/entrypoints.txt +++ b/libc/config/baremetal/arm/entrypoints.txt @@ -557,6 +557,7 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.nearbyintl libc.src.math.nextafter libc.src.math.nextafterf + libc.src.math.nextafterf128 libc.src.math.nextafterl libc.src.math.nextdown libc.src.math.nextdownf @@ -795,7 +796,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128) libc.src.math.logbf128 libc.src.math.modff128 libc.src.math.nanf128 - libc.src.math.nextafterf128 libc.src.math.nextdownf128 libc.src.math.nextupf128 libc.src.math.remainderf128 diff --git a/libc/config/baremetal/riscv/entrypoints.txt b/libc/config/baremetal/riscv/entrypoints.txt index 88613b39086a5..cceb699883149 100644 --- a/libc/config/baremetal/riscv/entrypoints.txt +++ b/libc/config/baremetal/riscv/entrypoints.txt @@ -553,6 +553,7 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.nearbyintl libc.src.math.nextafter libc.src.math.nextafterf + libc.src.math.nextafterf128 libc.src.math.nextafterl libc.src.math.nextdown libc.src.math.nextdownf @@ -792,7 +793,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128) libc.src.math.logbf128 libc.src.math.modff128 libc.src.math.nanf128 - libc.src.math.nextafterf128 libc.src.math.nextdownf128 libc.src.math.nextupf128 libc.src.math.remainderf128 diff --git a/libc/config/darwin/aarch64/entrypoints.txt b/libc/config/darwin/aarch64/entrypoints.txt index c6c8357207959..90e261cba1f1d 100644 --- a/libc/config/darwin/aarch64/entrypoints.txt +++ b/libc/config/darwin/aarch64/entrypoints.txt @@ -364,6 +364,7 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.nearbyintl libc.src.math.nextafter libc.src.math.nextafterf + libc.src.math.nextafterf128 libc.src.math.nextafterl libc.src.math.nextdown libc.src.math.nextdownf @@ -604,7 +605,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128) libc.src.math.logbf128 libc.src.math.modff128 libc.src.math.nanf128 - libc.src.math.nextafterf128 libc.src.math.nextdownf128 libc.src.math.nextupf128 libc.src.math.remainderf128 diff --git a/libc/config/darwin/x86_64/entrypoints.txt b/libc/config/darwin/x86_64/entrypoints.txt index 716ab572f8d3c..6222668ad851e 100644 --- a/libc/config/darwin/x86_64/entrypoints.txt +++ b/libc/config/darwin/x86_64/entrypoints.txt @@ -225,6 +225,7 @@ set(TARGET_LIBM_ENTRYPOINTS #libc.src.math.nearbyintl #libc.src.math.nextafter #libc.src.math.nextafterf + #libc.src.math.nextafterf128 #libc.src.math.nextafterl #libc.src.math.nexttoward #libc.src.math.nexttowardf diff --git a/libc/config/freebsd/x86_64/entrypoints.txt b/libc/config/freebsd/x86_64/entrypoints.txt index 3fed968bca141..14b3f2c6d8510 100644 --- a/libc/config/freebsd/x86_64/entrypoints.txt +++ b/libc/config/freebsd/x86_64/entrypoints.txt @@ -274,6 +274,7 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.nearbyintl libc.src.math.nextafter libc.src.math.nextafterf + libc.src.math.nextafterf128 libc.src.math.nextafterl libc.src.math.nexttoward libc.src.math.nexttowardf @@ -544,7 +545,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128) libc.src.math.logbf128 libc.src.math.modff128 libc.src.math.nanf128 - libc.src.math.nextafterf128 libc.src.math.nextdownf128 libc.src.math.nextupf128 libc.src.math.remainderf128 diff --git a/libc/config/gpu/amdgpu/entrypoints.txt b/libc/config/gpu/amdgpu/entrypoints.txt index c8d4708f38f7a..d223f99529267 100644 --- a/libc/config/gpu/amdgpu/entrypoints.txt +++ b/libc/config/gpu/amdgpu/entrypoints.txt @@ -488,6 +488,7 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.nearbyintl libc.src.math.nextafter libc.src.math.nextafterf + libc.src.math.nextafterf128 libc.src.math.nextafterl libc.src.math.nextdown libc.src.math.nextdownf diff --git a/libc/config/gpu/nvptx/entrypoints.txt b/libc/config/gpu/nvptx/entrypoints.txt index 78c504d392e44..0c51744f8e56b 100644 --- a/libc/config/gpu/nvptx/entrypoints.txt +++ b/libc/config/gpu/nvptx/entrypoints.txt @@ -485,6 +485,7 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.nearbyintl libc.src.math.nextafter libc.src.math.nextafterf + libc.src.math.nextafterf128 libc.src.math.nextafterl libc.src.math.nextdown libc.src.math.nextdownf diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt index 6eaefbe75db45..174778cee4b55 100644 --- a/libc/config/linux/aarch64/entrypoints.txt +++ b/libc/config/linux/aarch64/entrypoints.txt @@ -722,6 +722,7 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.nearbyintl libc.src.math.nextafter libc.src.math.nextafterf + libc.src.math.nextafterf128 libc.src.math.nextafterl libc.src.math.nextdown libc.src.math.nextdownf @@ -955,7 +956,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128) libc.src.math.logbf128 libc.src.math.modff128 libc.src.math.nanf128 - libc.src.math.nextafterf128 libc.src.math.nextdownf128 libc.src.math.nextupf128 libc.src.math.remainderf128 diff --git a/libc/config/linux/arm/entrypoints.txt b/libc/config/linux/arm/entrypoints.txt index 7a43eb92932d9..547b263677282 100644 --- a/libc/config/linux/arm/entrypoints.txt +++ b/libc/config/linux/arm/entrypoints.txt @@ -534,6 +534,7 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.nearbyintl libc.src.math.nextafter libc.src.math.nextafterf + libc.src.math.nextafterf128 libc.src.math.nextafterl libc.src.math.nextdown libc.src.math.nextdownf diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt index c9d405dc739a7..e8a8d0a5aa700 100644 --- a/libc/config/linux/riscv/entrypoints.txt +++ b/libc/config/linux/riscv/entrypoints.txt @@ -791,6 +791,7 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.nearbyintl libc.src.math.nextafter libc.src.math.nextafterf + libc.src.math.nextafterf128 libc.src.math.nextafterl libc.src.math.nextdown libc.src.math.nextdownf @@ -1041,7 +1042,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128) libc.src.math.logbf128 libc.src.math.modff128 libc.src.math.nanf128 - libc.src.math.nextafterf128 libc.src.math.nextdownf128 libc.src.math.nextupf128 libc.src.math.remainderf128 diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt index 7d5c25fb62e63..4e1cbece49910 100644 --- a/libc/config/linux/x86_64/entrypoints.txt +++ b/libc/config/linux/x86_64/entrypoints.txt @@ -800,6 +800,7 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.nearbyintl libc.src.math.nextafter libc.src.math.nextafterf + libc.src.math.nextafterf128 libc.src.math.nextafterl libc.src.math.nextdown libc.src.math.nextdownf @@ -1050,7 +1051,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128) libc.src.math.logbf128 libc.src.math.modff128 libc.src.math.nanf128 - libc.src.math.nextafterf128 libc.src.math.nextdownf128 libc.src.math.nextupf128 libc.src.math.remainderf128 diff --git a/libc/config/windows/entrypoints.txt b/libc/config/windows/entrypoints.txt index 8b8a1efc38910..7793eeea2295c 100644 --- a/libc/config/windows/entrypoints.txt +++ b/libc/config/windows/entrypoints.txt @@ -307,6 +307,7 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.nearbyintl libc.src.math.nextafter libc.src.math.nextafterf + libc.src.math.nextafterf128 libc.src.math.nextafterl libc.src.math.nexttoward libc.src.math.nexttowardf diff --git a/libc/shared/math/nextafterf128.h b/libc/shared/math/nextafterf128.h index 95bece2ba874a..6ff2087983a9f 100644 --- a/libc/shared/math/nextafterf128.h +++ b/libc/shared/math/nextafterf128.h @@ -9,10 +9,6 @@ #ifndef LLVM_LIBC_SHARED_MATH_NEXTAFTERF128_H #define LLVM_LIBC_SHARED_MATH_NEXTAFTERF128_H -#include "include/llvm-libc-types/float128.h" - -#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128 - #include "shared/libc_common.h" #include "src/__support/math/nextafterf128.h" @@ -24,6 +20,4 @@ using math::nextafterf128; } // namespace shared } // namespace LIBC_NAMESPACE_DECL -#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128 - #endif // LLVM_LIBC_SHARED_MATH_NEXTAFTERF128_H diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt index b24861f418e72..46008e369fd6f 100644 --- a/libc/src/__support/math/CMakeLists.txt +++ b/libc/src/__support/math/CMakeLists.txt @@ -4485,7 +4485,7 @@ add_header_library( HDRS nextafterf128.h DEPENDS - libc.include.llvm-libc-types.float128 + libc.src.__support.FPUtil.float128 libc.src.__support.FPUtil.manipulation_functions libc.src.__support.macros.config ) diff --git a/libc/src/__support/math/nextafterf128.h b/libc/src/__support/math/nextafterf128.h index d9c07b4d6b68f..ac4f6d0325e49 100644 --- a/libc/src/__support/math/nextafterf128.h +++ b/libc/src/__support/math/nextafterf128.h @@ -9,24 +9,21 @@ #ifndef LLVM_LIBC_SRC___SUPPORT_MATH_NEXTAFTERF128_H #define LLVM_LIBC_SRC___SUPPORT_MATH_NEXTAFTERF128_H -#include "include/llvm-libc-types/float128.h" - -#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128 - #include "src/__support/FPUtil/ManipulationFunctions.h" +#include "src/__support/FPUtil/float128.h" #include "src/__support/macros/config.h" namespace LIBC_NAMESPACE_DECL { namespace math { -LIBC_INLINE constexpr float128 nextafterf128(float128 x, float128 y) { +using LIBC_NAMESPACE::fputil::Float128; + +LIBC_INLINE constexpr Float128 nextafterf128(Float128 x, Float128 y) { return fputil::nextafter(x, y); } } // namespace math } // namespace LIBC_NAMESPACE_DECL -#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128 - #endif // LLVM_LIBC_SRC___SUPPORT_MATH_NEXTAFTERF128_H diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt index 28b8e954530dd..0d607faec42d9 100644 --- a/libc/src/math/generic/CMakeLists.txt +++ b/libc/src/math/generic/CMakeLists.txt @@ -3242,6 +3242,7 @@ add_entrypoint_object( HDRS ../nextafterf128.h DEPENDS + libc.src.__support.CPP.bit libc.src.__support.math.nextafterf128 ) diff --git a/libc/src/math/generic/nextafterf128.cpp b/libc/src/math/generic/nextafterf128.cpp index 3363db898fe0b..cdaf8a43e2c0f 100644 --- a/libc/src/math/generic/nextafterf128.cpp +++ b/libc/src/math/generic/nextafterf128.cpp @@ -7,12 +7,15 @@ //===----------------------------------------------------------------------===// #include "src/math/nextafterf128.h" +#include "src/__support/CPP/bit.h" #include "src/__support/math/nextafterf128.h" namespace LIBC_NAMESPACE_DECL { +using LIBC_NAMESPACE::fputil::Float128; + LLVM_LIBC_FUNCTION(float128, nextafterf128, (float128 x, float128 y)) { - return math::nextafterf128(x, y); + return cpp::bit_cast<float128>(math::nextafterf128(cpp::bit_cast<Float128>(x), cpp::bit_cast<Float128>(y))); } } // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/nextafterf128.h b/libc/src/math/nextafterf128.h index 99b15d6cf43b9..679ea23225faa 100644 --- a/libc/src/math/nextafterf128.h +++ b/libc/src/math/nextafterf128.h @@ -9,11 +9,16 @@ #ifndef LLVM_LIBC_SRC_MATH_NEXTAFTERF128_H #define LLVM_LIBC_SRC_MATH_NEXTAFTERF128_H +#include "src/__support/FPUtil/float128.h" #include "src/__support/macros/config.h" #include "src/__support/macros/properties/types.h" namespace LIBC_NAMESPACE_DECL { +#ifndef LIBC_TYPES_HAS_NATIVE_FLOAT128 +using float128 = LIBC_NAMESPACE::fputil::Float128; +#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128 + float128 nextafterf128(float128 x, float128 y); } // namespace LIBC_NAMESPACE_DECL diff --git a/libc/test/shared/shared_math_constexpr_test.cpp b/libc/test/shared/shared_math_constexpr_test.cpp index 64b8f6edadf52..cdd247b0d2f39 100644 --- a/libc/test/shared/shared_math_constexpr_test.cpp +++ b/libc/test/shared/shared_math_constexpr_test.cpp @@ -381,6 +381,7 @@ static_assert(0 == LIBC_NAMESPACE::shared::isnanl(0.0L)); //===----------------------------------------------------------------------===// static_assert(Float128(0.0) == LIBC_NAMESPACE::shared::ceilf128(Float128(0.0))); +static_assert(float128(0.0) == LIBC_NAMESPACE::shared::nextafterf128(Float128(0.0), Float128(0.0))); static_assert(Float128(0.0) == LIBC_NAMESPACE::shared::copysignf128(Float128(0.0), Float128(0.0))); @@ -502,9 +503,6 @@ static_assert(0.0f == LIBC_NAMESPACE::shared::fmulf128(float128(0.0), float128(0.0))); static_assert(0.0f == LIBC_NAMESPACE::shared::fsubf128(float128(0.0), float128(0.0))); -static_assert(float128(0.0) == - LIBC_NAMESPACE::shared::nextafterf128(float128(0.0), - float128(0.0))); static_assert(1 == [] { const char arg{}; return LIBC_NAMESPACE::fputil::FPBits<float128>( diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp index b197fd4cecfba..03029eed03705 100644 --- a/libc/test/shared/shared_math_test.cpp +++ b/libc/test/shared/shared_math_test.cpp @@ -584,6 +584,7 @@ TEST(LlvmLibcSharedMathTest, AllEmuFloat128) { EXPECT_FP_EQ(Float128(0.0), LIBC_NAMESPACE::shared::atan2f128(Float128(0.0), Float128(0.0))); EXPECT_FP_EQ(Float128(0.0), LIBC_NAMESPACE::shared::ceilf128(Float128(0.0))); + EXPECT_FP_EQ(float128(0.0), LIBC_NAMESPACE::shared::nextafterf128( Float128(0.0), Float128(0.0))); EXPECT_FP_EQ(Float128(0.0), LIBC_NAMESPACE::shared::copysignf128( Float128(0.0), Float128(0.0))); EXPECT_FP_EQ(Float128(0.0), LIBC_NAMESPACE::shared::fabsf128(Float128(0.0))); @@ -700,8 +701,6 @@ TEST(LlvmLibcSharedMathTest, AllFloat128) { LIBC_NAMESPACE::shared::nextdownf128(float128(0.0))); float128 min_denormal = FPBits::min_subnormal(Sign ::POS).get_val(); EXPECT_FP_EQ(min_denormal, LIBC_NAMESPACE::shared::nextupf128(float128(0.0))); - EXPECT_FP_EQ(float128(0.0), LIBC_NAMESPACE::shared::nextafterf128( - float128(0.0), float128(0.0))); #ifdef LIBC_TYPES_HAS_FLOAT16 EXPECT_FP_EQ(10.0f16, LIBC_NAMESPACE::shared::f16fmaf128( diff --git a/libc/test/src/math/CMakeLists.txt b/libc/test/src/math/CMakeLists.txt index 8f1a543de0a5e..2c638a35911c9 100644 --- a/libc/test/src/math/CMakeLists.txt +++ b/libc/test/src/math/CMakeLists.txt @@ -2244,6 +2244,7 @@ add_fp_unittest( HDRS NextAfterTest.h DEPENDS + libc.src.__support.FPUtil.float128 libc.src.math.nextafterf128 libc.src.__support.FPUtil.basic_operations libc.src.__support.FPUtil.fp_bits diff --git a/libc/test/src/math/nextafterf128_test.cpp b/libc/test/src/math/nextafterf128_test.cpp index a8d000ff4de38..9ee60ef21cffe 100644 --- a/libc/test/src/math/nextafterf128_test.cpp +++ b/libc/test/src/math/nextafterf128_test.cpp @@ -7,7 +7,12 @@ //===----------------------------------------------------------------------===// #include "NextAfterTest.h" +#include "src/__support/FPUtil/float128.h" #include "src/math/nextafterf128.h" +#ifndef LIBC_TYPES_HAS_NATIVE_FLOAT128 +using float128 = LIBC_NAMESPACE::fputil::Float128; +#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128 + LIST_NEXTAFTER_TESTS(float128, LIBC_NAMESPACE::nextafterf128) diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt index deb286e6d6ed6..9e7d236b83309 100644 --- a/libc/test/src/math/smoke/CMakeLists.txt +++ b/libc/test/src/math/smoke/CMakeLists.txt @@ -4109,6 +4109,7 @@ add_fp_unittest( NextAfterTest.h DEPENDS libc.hdr.fenv_macros + libc.src.__support.FPUtil.float128 libc.src.math.nextafterf128 libc.src.__support.CPP.bit libc.src.__support.FPUtil.fenv_impl diff --git a/libc/test/src/math/smoke/nextafterf128_test.cpp b/libc/test/src/math/smoke/nextafterf128_test.cpp index a8d000ff4de38..9ee60ef21cffe 100644 --- a/libc/test/src/math/smoke/nextafterf128_test.cpp +++ b/libc/test/src/math/smoke/nextafterf128_test.cpp @@ -7,7 +7,12 @@ //===----------------------------------------------------------------------===// #include "NextAfterTest.h" +#include "src/__support/FPUtil/float128.h" #include "src/math/nextafterf128.h" +#ifndef LIBC_TYPES_HAS_NATIVE_FLOAT128 +using float128 = LIBC_NAMESPACE::fputil::Float128; +#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128 + LIST_NEXTAFTER_TESTS(float128, LIBC_NAMESPACE::nextafterf128) diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel index c3efbe2e23d8c..39f7f810a6c87 100644 --- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel @@ -8486,9 +8486,9 @@ libc_support_library( name = "__support_math_nextafterf128", hdrs = ["src/__support/math/nextafterf128.h"], deps = [ + ":__support_fputil_float128", ":__support_fputil_manipulation_functions", ":__support_macros_config", - ":llvm_libc_types_float128", ], ) @@ -13099,6 +13099,8 @@ libc_math_function( libc_math_function( name = "nextafterf128", additional_deps = [ + ":__support_cpp_bit", + ":__support_fputil_float128", ":__support_math_nextafterf128", ], ) diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel index 1ea19f953e0ad..db2b87b017bc9 100644 --- a/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel @@ -1304,6 +1304,9 @@ math_test( name = "nextafterf128", hdrs = ["NextAfterTest.h"], deps = ["//libc:__support_sign"], + deps = [ + "//libc:__support_fputil_float128", + ], ) math_test( >From 88caceee6de8540fc83de5227e914d862f92f3ab Mon Sep 17 00:00:00 2001 From: Sukumarsawant <[email protected]> Date: Thu, 20 Aug 2026 15:36:00 +0530 Subject: [PATCH 2/4] nextupf128 --- libc/config/baremetal/aarch64/entrypoints.txt | 2 +- libc/config/baremetal/arm/entrypoints.txt | 2 +- libc/config/baremetal/riscv/entrypoints.txt | 2 +- libc/config/darwin/aarch64/entrypoints.txt | 2 +- libc/config/darwin/x86_64/entrypoints.txt | 1 + libc/config/freebsd/x86_64/entrypoints.txt | 2 +- libc/config/gpu/amdgpu/entrypoints.txt | 1 + libc/config/gpu/nvptx/entrypoints.txt | 1 + libc/config/linux/aarch64/entrypoints.txt | 2 +- libc/config/linux/arm/entrypoints.txt | 1 + libc/config/linux/riscv/entrypoints.txt | 2 +- libc/config/linux/x86_64/entrypoints.txt | 2 +- libc/config/windows/entrypoints.txt | 1 + libc/shared/math/nextupf128.h | 6 ------ libc/src/__support/math/CMakeLists.txt | 2 +- libc/src/__support/math/nextupf128.h | 11 ++++------- libc/src/math/generic/CMakeLists.txt | 1 + libc/src/math/generic/nextafterf128.cpp | 3 ++- libc/src/math/generic/nextupf128.cpp | 5 ++++- libc/src/math/nextupf128.h | 5 +++++ libc/test/shared/shared_math_constexpr_test.cpp | 4 +++- libc/test/shared/shared_math_test.cpp | 5 +++-- libc/test/src/math/smoke/CMakeLists.txt | 1 + libc/test/src/math/smoke/nextupf128_test.cpp | 5 +++++ utils/bazel/llvm-project-overlay/libc/BUILD.bazel | 4 +++- .../libc/test/src/math/smoke/BUILD.bazel | 3 +++ 26 files changed, 48 insertions(+), 28 deletions(-) diff --git a/libc/config/baremetal/aarch64/entrypoints.txt b/libc/config/baremetal/aarch64/entrypoints.txt index d975c783447da..0b6732f821a63 100644 --- a/libc/config/baremetal/aarch64/entrypoints.txt +++ b/libc/config/baremetal/aarch64/entrypoints.txt @@ -555,6 +555,7 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.nexttowardl libc.src.math.nextup libc.src.math.nextupf + libc.src.math.nextupf128 libc.src.math.nextupl libc.src.math.pow libc.src.math.powf @@ -786,7 +787,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128) libc.src.math.modff128 libc.src.math.nanf128 libc.src.math.nextdownf128 - libc.src.math.nextupf128 libc.src.math.remainderf128 libc.src.math.remquof128 libc.src.math.scalblnf128 diff --git a/libc/config/baremetal/arm/entrypoints.txt b/libc/config/baremetal/arm/entrypoints.txt index 751162df15496..d976f1fc2adb8 100644 --- a/libc/config/baremetal/arm/entrypoints.txt +++ b/libc/config/baremetal/arm/entrypoints.txt @@ -567,6 +567,7 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.nexttowardl libc.src.math.nextup libc.src.math.nextupf + libc.src.math.nextupf128 libc.src.math.nextupl libc.src.math.pow libc.src.math.powf @@ -797,7 +798,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128) libc.src.math.modff128 libc.src.math.nanf128 libc.src.math.nextdownf128 - libc.src.math.nextupf128 libc.src.math.remainderf128 libc.src.math.remquof128 libc.src.math.scalblnf128 diff --git a/libc/config/baremetal/riscv/entrypoints.txt b/libc/config/baremetal/riscv/entrypoints.txt index cceb699883149..083efe745fbd9 100644 --- a/libc/config/baremetal/riscv/entrypoints.txt +++ b/libc/config/baremetal/riscv/entrypoints.txt @@ -563,6 +563,7 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.nexttowardl libc.src.math.nextup libc.src.math.nextupf + libc.src.math.nextupf128 libc.src.math.nextupl libc.src.math.pow libc.src.math.powf @@ -794,7 +795,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128) libc.src.math.modff128 libc.src.math.nanf128 libc.src.math.nextdownf128 - libc.src.math.nextupf128 libc.src.math.remainderf128 libc.src.math.remquof128 libc.src.math.scalblnf128 diff --git a/libc/config/darwin/aarch64/entrypoints.txt b/libc/config/darwin/aarch64/entrypoints.txt index 90e261cba1f1d..a776f335bd3de 100644 --- a/libc/config/darwin/aarch64/entrypoints.txt +++ b/libc/config/darwin/aarch64/entrypoints.txt @@ -374,6 +374,7 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.nexttowardl libc.src.math.nextup libc.src.math.nextupf + libc.src.math.nextupf128 libc.src.math.nextupl libc.src.math.pow libc.src.math.powf @@ -606,7 +607,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128) libc.src.math.modff128 libc.src.math.nanf128 libc.src.math.nextdownf128 - libc.src.math.nextupf128 libc.src.math.remainderf128 libc.src.math.remquof128 libc.src.math.scalblnf128 diff --git a/libc/config/darwin/x86_64/entrypoints.txt b/libc/config/darwin/x86_64/entrypoints.txt index 6222668ad851e..4291bee1b210e 100644 --- a/libc/config/darwin/x86_64/entrypoints.txt +++ b/libc/config/darwin/x86_64/entrypoints.txt @@ -230,6 +230,7 @@ set(TARGET_LIBM_ENTRYPOINTS #libc.src.math.nexttoward #libc.src.math.nexttowardf #libc.src.math.nexttowardl + #libc.src.math.nextupf128 #libc.src.math.remainderf #libc.src.math.remainder #libc.src.math.remainderl diff --git a/libc/config/freebsd/x86_64/entrypoints.txt b/libc/config/freebsd/x86_64/entrypoints.txt index 14b3f2c6d8510..c71c49ec70ebc 100644 --- a/libc/config/freebsd/x86_64/entrypoints.txt +++ b/libc/config/freebsd/x86_64/entrypoints.txt @@ -279,6 +279,7 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.nexttoward libc.src.math.nexttowardf libc.src.math.nexttowardl + libc.src.math.nextupf128 libc.src.math.pow libc.src.math.powf libc.src.math.remainderf @@ -546,7 +547,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128) libc.src.math.modff128 libc.src.math.nanf128 libc.src.math.nextdownf128 - libc.src.math.nextupf128 libc.src.math.remainderf128 libc.src.math.remquof128 libc.src.math.scalblnf128 diff --git a/libc/config/gpu/amdgpu/entrypoints.txt b/libc/config/gpu/amdgpu/entrypoints.txt index d223f99529267..33703cce7d9e7 100644 --- a/libc/config/gpu/amdgpu/entrypoints.txt +++ b/libc/config/gpu/amdgpu/entrypoints.txt @@ -498,6 +498,7 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.nexttowardl libc.src.math.nextup libc.src.math.nextupf + libc.src.math.nextupf128 libc.src.math.nextupl libc.src.math.pow libc.src.math.powf diff --git a/libc/config/gpu/nvptx/entrypoints.txt b/libc/config/gpu/nvptx/entrypoints.txt index 0c51744f8e56b..aca6d9aba3acd 100644 --- a/libc/config/gpu/nvptx/entrypoints.txt +++ b/libc/config/gpu/nvptx/entrypoints.txt @@ -495,6 +495,7 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.nexttowardl libc.src.math.nextup libc.src.math.nextupf + libc.src.math.nextupf128 libc.src.math.nextupl libc.src.math.pow libc.src.math.powf diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt index 174778cee4b55..10bf9b724357f 100644 --- a/libc/config/linux/aarch64/entrypoints.txt +++ b/libc/config/linux/aarch64/entrypoints.txt @@ -732,6 +732,7 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.nexttowardl libc.src.math.nextup libc.src.math.nextupf + libc.src.math.nextupf128 libc.src.math.nextupl libc.src.math.pow libc.src.math.powf @@ -957,7 +958,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128) libc.src.math.modff128 libc.src.math.nanf128 libc.src.math.nextdownf128 - libc.src.math.nextupf128 libc.src.math.remainderf128 libc.src.math.remquof128 libc.src.math.scalblnf128 diff --git a/libc/config/linux/arm/entrypoints.txt b/libc/config/linux/arm/entrypoints.txt index 547b263677282..ba6eb727e8bb4 100644 --- a/libc/config/linux/arm/entrypoints.txt +++ b/libc/config/linux/arm/entrypoints.txt @@ -544,6 +544,7 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.nexttowardl libc.src.math.nextup libc.src.math.nextupf + libc.src.math.nextupf128 libc.src.math.nextupl libc.src.math.pow libc.src.math.powf diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt index e8a8d0a5aa700..d93ab581fd5e4 100644 --- a/libc/config/linux/riscv/entrypoints.txt +++ b/libc/config/linux/riscv/entrypoints.txt @@ -801,6 +801,7 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.nexttowardl libc.src.math.nextup libc.src.math.nextupf + libc.src.math.nextupf128 libc.src.math.nextupl libc.src.math.pow libc.src.math.powf @@ -1043,7 +1044,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128) libc.src.math.modff128 libc.src.math.nanf128 libc.src.math.nextdownf128 - libc.src.math.nextupf128 libc.src.math.remainderf128 libc.src.math.remquof128 libc.src.math.scalblnf128 diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt index 4e1cbece49910..578df8ea51353 100644 --- a/libc/config/linux/x86_64/entrypoints.txt +++ b/libc/config/linux/x86_64/entrypoints.txt @@ -810,6 +810,7 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.nexttowardl libc.src.math.nextup libc.src.math.nextupf + libc.src.math.nextupf128 libc.src.math.nextupl libc.src.math.pow libc.src.math.powf @@ -1052,7 +1053,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128) libc.src.math.modff128 libc.src.math.nanf128 libc.src.math.nextdownf128 - libc.src.math.nextupf128 libc.src.math.remainderf128 libc.src.math.remquof128 libc.src.math.scalblnf128 diff --git a/libc/config/windows/entrypoints.txt b/libc/config/windows/entrypoints.txt index 7793eeea2295c..6a7d63bfce806 100644 --- a/libc/config/windows/entrypoints.txt +++ b/libc/config/windows/entrypoints.txt @@ -312,6 +312,7 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.nexttoward libc.src.math.nexttowardf libc.src.math.nexttowardl + libc.src.math.nextupf128 libc.src.math.pow libc.src.math.powf libc.src.math.remainderf diff --git a/libc/shared/math/nextupf128.h b/libc/shared/math/nextupf128.h index 4d8312efa9311..6da0606a3cbe6 100644 --- a/libc/shared/math/nextupf128.h +++ b/libc/shared/math/nextupf128.h @@ -9,10 +9,6 @@ #ifndef LLVM_LIBC_SHARED_MATH_NEXTUPF128_H #define LLVM_LIBC_SHARED_MATH_NEXTUPF128_H -#include "include/llvm-libc-types/float128.h" - -#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128 - #include "shared/libc_common.h" #include "src/__support/math/nextupf128.h" @@ -24,6 +20,4 @@ using math::nextupf128; } // namespace shared } // namespace LIBC_NAMESPACE_DECL -#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128 - #endif // LLVM_LIBC_SHARED_MATH_NEXTUPF128_H diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt index 46008e369fd6f..ae147c90c5f1b 100644 --- a/libc/src/__support/math/CMakeLists.txt +++ b/libc/src/__support/math/CMakeLists.txt @@ -4589,7 +4589,7 @@ add_header_library( HDRS nextupf128.h DEPENDS - libc.include.llvm-libc-types.float128 + libc.src.__support.FPUtil.float128 libc.src.__support.FPUtil.manipulation_functions libc.src.__support.macros.config ) diff --git a/libc/src/__support/math/nextupf128.h b/libc/src/__support/math/nextupf128.h index 2b618e4095968..42f0d6444a2c5 100644 --- a/libc/src/__support/math/nextupf128.h +++ b/libc/src/__support/math/nextupf128.h @@ -9,24 +9,21 @@ #ifndef LLVM_LIBC_SRC___SUPPORT_MATH_NEXTUPF128_H #define LLVM_LIBC_SRC___SUPPORT_MATH_NEXTUPF128_H -#include "include/llvm-libc-types/float128.h" - -#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128 - #include "src/__support/FPUtil/ManipulationFunctions.h" +#include "src/__support/FPUtil/float128.h" #include "src/__support/macros/config.h" namespace LIBC_NAMESPACE_DECL { namespace math { -LIBC_INLINE constexpr float128 nextupf128(float128 x) { +using LIBC_NAMESPACE::fputil::Float128; + +LIBC_INLINE constexpr Float128 nextupf128(Float128 x) { return fputil::nextupdown</*IsDown=*/false>(x); } } // namespace math } // namespace LIBC_NAMESPACE_DECL -#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128 - #endif // LLVM_LIBC_SRC___SUPPORT_MATH_NEXTUPF128_H diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt index 0d607faec42d9..2b544930c9f71 100644 --- a/libc/src/math/generic/CMakeLists.txt +++ b/libc/src/math/generic/CMakeLists.txt @@ -3413,6 +3413,7 @@ add_entrypoint_object( HDRS ../nextupf128.h DEPENDS + libc.src.__support.CPP.bit libc.src.__support.math.nextupf128 ) diff --git a/libc/src/math/generic/nextafterf128.cpp b/libc/src/math/generic/nextafterf128.cpp index cdaf8a43e2c0f..5e0f862fb5c4d 100644 --- a/libc/src/math/generic/nextafterf128.cpp +++ b/libc/src/math/generic/nextafterf128.cpp @@ -15,7 +15,8 @@ namespace LIBC_NAMESPACE_DECL { using LIBC_NAMESPACE::fputil::Float128; LLVM_LIBC_FUNCTION(float128, nextafterf128, (float128 x, float128 y)) { - return cpp::bit_cast<float128>(math::nextafterf128(cpp::bit_cast<Float128>(x), cpp::bit_cast<Float128>(y))); + return cpp::bit_cast<float128>(math::nextafterf128( + cpp::bit_cast<Float128>(x), cpp::bit_cast<Float128>(y))); } } // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/generic/nextupf128.cpp b/libc/src/math/generic/nextupf128.cpp index 71a7b20b86741..f5e8e98870a65 100644 --- a/libc/src/math/generic/nextupf128.cpp +++ b/libc/src/math/generic/nextupf128.cpp @@ -7,12 +7,15 @@ //===----------------------------------------------------------------------===// #include "src/math/nextupf128.h" +#include "src/__support/CPP/bit.h" #include "src/__support/math/nextupf128.h" namespace LIBC_NAMESPACE_DECL { +using LIBC_NAMESPACE::fputil::Float128; + LLVM_LIBC_FUNCTION(float128, nextupf128, (float128 x)) { - return math::nextupf128(x); + return cpp::bit_cast<float128>(math::nextupf128(cpp::bit_cast<Float128>(x))); } } // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/nextupf128.h b/libc/src/math/nextupf128.h index 755c08d891d64..8e911b5aa6fad 100644 --- a/libc/src/math/nextupf128.h +++ b/libc/src/math/nextupf128.h @@ -9,11 +9,16 @@ #ifndef LLVM_LIBC_SRC_MATH_NEXTUPF128_H #define LLVM_LIBC_SRC_MATH_NEXTUPF128_H +#include "src/__support/FPUtil/float128.h" #include "src/__support/macros/config.h" #include "src/__support/macros/properties/types.h" namespace LIBC_NAMESPACE_DECL { +#ifndef LIBC_TYPES_HAS_NATIVE_FLOAT128 +using float128 = LIBC_NAMESPACE::fputil::Float128; +#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128 + float128 nextupf128(float128 x); } // namespace LIBC_NAMESPACE_DECL diff --git a/libc/test/shared/shared_math_constexpr_test.cpp b/libc/test/shared/shared_math_constexpr_test.cpp index cdd247b0d2f39..a4001cdc365d0 100644 --- a/libc/test/shared/shared_math_constexpr_test.cpp +++ b/libc/test/shared/shared_math_constexpr_test.cpp @@ -381,7 +381,9 @@ static_assert(0 == LIBC_NAMESPACE::shared::isnanl(0.0L)); //===----------------------------------------------------------------------===// static_assert(Float128(0.0) == LIBC_NAMESPACE::shared::ceilf128(Float128(0.0))); -static_assert(float128(0.0) == LIBC_NAMESPACE::shared::nextafterf128(Float128(0.0), Float128(0.0))); +static_assert(float128(0.0) == + LIBC_NAMESPACE::shared::nextafterf128(Float128(0.0), + Float128(0.0))); static_assert(Float128(0.0) == LIBC_NAMESPACE::shared::copysignf128(Float128(0.0), Float128(0.0))); diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp index 03029eed03705..e97e1a3c62918 100644 --- a/libc/test/shared/shared_math_test.cpp +++ b/libc/test/shared/shared_math_test.cpp @@ -584,7 +584,9 @@ TEST(LlvmLibcSharedMathTest, AllEmuFloat128) { EXPECT_FP_EQ(Float128(0.0), LIBC_NAMESPACE::shared::atan2f128(Float128(0.0), Float128(0.0))); EXPECT_FP_EQ(Float128(0.0), LIBC_NAMESPACE::shared::ceilf128(Float128(0.0))); - EXPECT_FP_EQ(float128(0.0), LIBC_NAMESPACE::shared::nextafterf128( Float128(0.0), Float128(0.0))); + EXPECT_FP_EQ(min_denormal, LIBC_NAMESPACE::shared::nextupf128(Float128(0.0))); + EXPECT_FP_EQ(float128(0.0), LIBC_NAMESPACE::shared::nextafterf128( + Float128(0.0), Float128(0.0))); EXPECT_FP_EQ(Float128(0.0), LIBC_NAMESPACE::shared::copysignf128( Float128(0.0), Float128(0.0))); EXPECT_FP_EQ(Float128(0.0), LIBC_NAMESPACE::shared::fabsf128(Float128(0.0))); @@ -700,7 +702,6 @@ TEST(LlvmLibcSharedMathTest, AllFloat128) { EXPECT_FP_EQ(neg_min_denormal, LIBC_NAMESPACE::shared::nextdownf128(float128(0.0))); float128 min_denormal = FPBits::min_subnormal(Sign ::POS).get_val(); - EXPECT_FP_EQ(min_denormal, LIBC_NAMESPACE::shared::nextupf128(float128(0.0))); #ifdef LIBC_TYPES_HAS_FLOAT16 EXPECT_FP_EQ(10.0f16, LIBC_NAMESPACE::shared::f16fmaf128( diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt index 9e7d236b83309..634f4cefa9aeb 100644 --- a/libc/test/src/math/smoke/CMakeLists.txt +++ b/libc/test/src/math/smoke/CMakeLists.txt @@ -4347,6 +4347,7 @@ add_fp_unittest( HDRS NextUpTest.h DEPENDS + libc.src.__support.FPUtil.float128 libc.src.math.nextupf128 ) diff --git a/libc/test/src/math/smoke/nextupf128_test.cpp b/libc/test/src/math/smoke/nextupf128_test.cpp index ddd385a7b159b..96cc6932ccea8 100644 --- a/libc/test/src/math/smoke/nextupf128_test.cpp +++ b/libc/test/src/math/smoke/nextupf128_test.cpp @@ -7,7 +7,12 @@ //===----------------------------------------------------------------------===// #include "NextUpTest.h" +#include "src/__support/FPUtil/float128.h" #include "src/math/nextupf128.h" +#ifndef LIBC_TYPES_HAS_NATIVE_FLOAT128 +using float128 = LIBC_NAMESPACE::fputil::Float128; +#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128 + LIST_NEXTUP_TESTS(float128, LIBC_NAMESPACE::nextupf128) diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel index 39f7f810a6c87..1491c6ef33f49 100644 --- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel @@ -8648,9 +8648,9 @@ libc_support_library( name = "__support_math_nextupf128", hdrs = ["src/__support/math/nextupf128.h"], deps = [ + ":__support_fputil_float128", ":__support_fputil_manipulation_functions", ":__support_macros_config", - ":llvm_libc_types_float128", ], ) @@ -13213,6 +13213,8 @@ libc_math_function( libc_math_function( name = "nextupf128", additional_deps = [ + ":__support_cpp_bit", + ":__support_fputil_float128", ":__support_math_nextupf128", ], ) diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel index db2b87b017bc9..abbb48380b528 100644 --- a/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel @@ -1378,6 +1378,9 @@ math_test( math_test( name = "nextupf128", hdrs = ["NextUpTest.h"], + deps = [ + "//libc:__support_fputil_float128", + ], ) math_test( >From ac7c57e7813a039e073378c82d02172be25289ab Mon Sep 17 00:00:00 2001 From: Sukumarsawant <[email protected]> Date: Thu, 20 Aug 2026 15:40:46 +0530 Subject: [PATCH 3/4] nextdownf128 --- libc/config/baremetal/aarch64/entrypoints.txt | 2 +- libc/config/baremetal/arm/entrypoints.txt | 2 +- libc/config/baremetal/riscv/entrypoints.txt | 2 +- libc/config/darwin/aarch64/entrypoints.txt | 2 +- libc/config/darwin/x86_64/entrypoints.txt | 1 + libc/config/freebsd/x86_64/entrypoints.txt | 2 +- libc/config/gpu/amdgpu/entrypoints.txt | 1 + libc/config/gpu/nvptx/entrypoints.txt | 1 + libc/config/linux/aarch64/entrypoints.txt | 2 +- libc/config/linux/arm/entrypoints.txt | 1 + libc/config/linux/riscv/entrypoints.txt | 2 +- libc/config/linux/x86_64/entrypoints.txt | 2 +- libc/config/windows/entrypoints.txt | 1 + libc/shared/math/nextdownf128.h | 6 ------ libc/src/__support/math/CMakeLists.txt | 2 +- libc/src/__support/math/nextdownf128.h | 11 ++++------- libc/src/math/generic/CMakeLists.txt | 1 + libc/src/math/generic/nextdownf128.cpp | 6 +++++- libc/src/math/nextdownf128.h | 5 +++++ libc/test/shared/shared_math_constexpr_test.cpp | 6 +++--- libc/test/shared/shared_math_test.cpp | 13 ++++++++----- libc/test/src/math/smoke/CMakeLists.txt | 1 + libc/test/src/math/smoke/nextdownf128_test.cpp | 5 +++++ utils/bazel/llvm-project-overlay/libc/BUILD.bazel | 4 +++- .../libc/test/src/math/smoke/BUILD.bazel | 3 +++ 25 files changed, 52 insertions(+), 32 deletions(-) diff --git a/libc/config/baremetal/aarch64/entrypoints.txt b/libc/config/baremetal/aarch64/entrypoints.txt index 0b6732f821a63..66911050bbf4a 100644 --- a/libc/config/baremetal/aarch64/entrypoints.txt +++ b/libc/config/baremetal/aarch64/entrypoints.txt @@ -549,6 +549,7 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.nextafterl libc.src.math.nextdown libc.src.math.nextdownf + libc.src.math.nextdownf128 libc.src.math.nextdownl libc.src.math.nexttoward libc.src.math.nexttowardf @@ -786,7 +787,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128) libc.src.math.logbf128 libc.src.math.modff128 libc.src.math.nanf128 - libc.src.math.nextdownf128 libc.src.math.remainderf128 libc.src.math.remquof128 libc.src.math.scalblnf128 diff --git a/libc/config/baremetal/arm/entrypoints.txt b/libc/config/baremetal/arm/entrypoints.txt index d976f1fc2adb8..ef01c5a9e07fb 100644 --- a/libc/config/baremetal/arm/entrypoints.txt +++ b/libc/config/baremetal/arm/entrypoints.txt @@ -561,6 +561,7 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.nextafterl libc.src.math.nextdown libc.src.math.nextdownf + libc.src.math.nextdownf128 libc.src.math.nextdownl libc.src.math.nexttoward libc.src.math.nexttowardf @@ -797,7 +798,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128) libc.src.math.logbf128 libc.src.math.modff128 libc.src.math.nanf128 - libc.src.math.nextdownf128 libc.src.math.remainderf128 libc.src.math.remquof128 libc.src.math.scalblnf128 diff --git a/libc/config/baremetal/riscv/entrypoints.txt b/libc/config/baremetal/riscv/entrypoints.txt index 083efe745fbd9..3313ac9b6be4c 100644 --- a/libc/config/baremetal/riscv/entrypoints.txt +++ b/libc/config/baremetal/riscv/entrypoints.txt @@ -557,6 +557,7 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.nextafterl libc.src.math.nextdown libc.src.math.nextdownf + libc.src.math.nextdownf128 libc.src.math.nextdownl libc.src.math.nexttoward libc.src.math.nexttowardf @@ -794,7 +795,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128) libc.src.math.logbf128 libc.src.math.modff128 libc.src.math.nanf128 - libc.src.math.nextdownf128 libc.src.math.remainderf128 libc.src.math.remquof128 libc.src.math.scalblnf128 diff --git a/libc/config/darwin/aarch64/entrypoints.txt b/libc/config/darwin/aarch64/entrypoints.txt index a776f335bd3de..a7b95b744e960 100644 --- a/libc/config/darwin/aarch64/entrypoints.txt +++ b/libc/config/darwin/aarch64/entrypoints.txt @@ -368,6 +368,7 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.nextafterl libc.src.math.nextdown libc.src.math.nextdownf + libc.src.math.nextdownf128 libc.src.math.nextdownl libc.src.math.nexttoward libc.src.math.nexttowardf @@ -606,7 +607,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128) libc.src.math.logbf128 libc.src.math.modff128 libc.src.math.nanf128 - libc.src.math.nextdownf128 libc.src.math.remainderf128 libc.src.math.remquof128 libc.src.math.scalblnf128 diff --git a/libc/config/darwin/x86_64/entrypoints.txt b/libc/config/darwin/x86_64/entrypoints.txt index 4291bee1b210e..3e38ac38b3791 100644 --- a/libc/config/darwin/x86_64/entrypoints.txt +++ b/libc/config/darwin/x86_64/entrypoints.txt @@ -227,6 +227,7 @@ set(TARGET_LIBM_ENTRYPOINTS #libc.src.math.nextafterf #libc.src.math.nextafterf128 #libc.src.math.nextafterl + #libc.src.math.nextdownf128 #libc.src.math.nexttoward #libc.src.math.nexttowardf #libc.src.math.nexttowardl diff --git a/libc/config/freebsd/x86_64/entrypoints.txt b/libc/config/freebsd/x86_64/entrypoints.txt index c71c49ec70ebc..5bf25d849e281 100644 --- a/libc/config/freebsd/x86_64/entrypoints.txt +++ b/libc/config/freebsd/x86_64/entrypoints.txt @@ -276,6 +276,7 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.nextafterf libc.src.math.nextafterf128 libc.src.math.nextafterl + libc.src.math.nextdownf128 libc.src.math.nexttoward libc.src.math.nexttowardf libc.src.math.nexttowardl @@ -546,7 +547,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128) libc.src.math.logbf128 libc.src.math.modff128 libc.src.math.nanf128 - libc.src.math.nextdownf128 libc.src.math.remainderf128 libc.src.math.remquof128 libc.src.math.scalblnf128 diff --git a/libc/config/gpu/amdgpu/entrypoints.txt b/libc/config/gpu/amdgpu/entrypoints.txt index 33703cce7d9e7..b81aabde82a3b 100644 --- a/libc/config/gpu/amdgpu/entrypoints.txt +++ b/libc/config/gpu/amdgpu/entrypoints.txt @@ -492,6 +492,7 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.nextafterl libc.src.math.nextdown libc.src.math.nextdownf + libc.src.math.nextdownf128 libc.src.math.nextdownl libc.src.math.nexttoward libc.src.math.nexttowardf diff --git a/libc/config/gpu/nvptx/entrypoints.txt b/libc/config/gpu/nvptx/entrypoints.txt index aca6d9aba3acd..c930b09c5253c 100644 --- a/libc/config/gpu/nvptx/entrypoints.txt +++ b/libc/config/gpu/nvptx/entrypoints.txt @@ -489,6 +489,7 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.nextafterl libc.src.math.nextdown libc.src.math.nextdownf + libc.src.math.nextdownf128 libc.src.math.nextdownl libc.src.math.nexttoward libc.src.math.nexttowardf diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt index 10bf9b724357f..0139010390342 100644 --- a/libc/config/linux/aarch64/entrypoints.txt +++ b/libc/config/linux/aarch64/entrypoints.txt @@ -726,6 +726,7 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.nextafterl libc.src.math.nextdown libc.src.math.nextdownf + libc.src.math.nextdownf128 libc.src.math.nextdownl libc.src.math.nexttoward libc.src.math.nexttowardf @@ -957,7 +958,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128) libc.src.math.logbf128 libc.src.math.modff128 libc.src.math.nanf128 - libc.src.math.nextdownf128 libc.src.math.remainderf128 libc.src.math.remquof128 libc.src.math.scalblnf128 diff --git a/libc/config/linux/arm/entrypoints.txt b/libc/config/linux/arm/entrypoints.txt index ba6eb727e8bb4..095a4cc279c17 100644 --- a/libc/config/linux/arm/entrypoints.txt +++ b/libc/config/linux/arm/entrypoints.txt @@ -538,6 +538,7 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.nextafterl libc.src.math.nextdown libc.src.math.nextdownf + libc.src.math.nextdownf128 libc.src.math.nextdownl libc.src.math.nexttoward libc.src.math.nexttowardf diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt index d93ab581fd5e4..f69dad1d74633 100644 --- a/libc/config/linux/riscv/entrypoints.txt +++ b/libc/config/linux/riscv/entrypoints.txt @@ -795,6 +795,7 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.nextafterl libc.src.math.nextdown libc.src.math.nextdownf + libc.src.math.nextdownf128 libc.src.math.nextdownl libc.src.math.nexttoward libc.src.math.nexttowardf @@ -1043,7 +1044,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128) libc.src.math.logbf128 libc.src.math.modff128 libc.src.math.nanf128 - libc.src.math.nextdownf128 libc.src.math.remainderf128 libc.src.math.remquof128 libc.src.math.scalblnf128 diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt index 578df8ea51353..5e80a8d31b136 100644 --- a/libc/config/linux/x86_64/entrypoints.txt +++ b/libc/config/linux/x86_64/entrypoints.txt @@ -804,6 +804,7 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.nextafterl libc.src.math.nextdown libc.src.math.nextdownf + libc.src.math.nextdownf128 libc.src.math.nextdownl libc.src.math.nexttoward libc.src.math.nexttowardf @@ -1052,7 +1053,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128) libc.src.math.logbf128 libc.src.math.modff128 libc.src.math.nanf128 - libc.src.math.nextdownf128 libc.src.math.remainderf128 libc.src.math.remquof128 libc.src.math.scalblnf128 diff --git a/libc/config/windows/entrypoints.txt b/libc/config/windows/entrypoints.txt index 6a7d63bfce806..ce79244ddf760 100644 --- a/libc/config/windows/entrypoints.txt +++ b/libc/config/windows/entrypoints.txt @@ -309,6 +309,7 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.nextafterf libc.src.math.nextafterf128 libc.src.math.nextafterl + libc.src.math.nextdownf128 libc.src.math.nexttoward libc.src.math.nexttowardf libc.src.math.nexttowardl diff --git a/libc/shared/math/nextdownf128.h b/libc/shared/math/nextdownf128.h index 958d1f2cc5297..902a101dfb19d 100644 --- a/libc/shared/math/nextdownf128.h +++ b/libc/shared/math/nextdownf128.h @@ -9,10 +9,6 @@ #ifndef LLVM_LIBC_SHARED_MATH_NEXTDOWNF128_H #define LLVM_LIBC_SHARED_MATH_NEXTDOWNF128_H -#include "include/llvm-libc-types/float128.h" - -#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128 - #include "shared/libc_common.h" #include "src/__support/math/nextdownf128.h" @@ -24,6 +20,4 @@ using math::nextdownf128; } // namespace shared } // namespace LIBC_NAMESPACE_DECL -#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128 - #endif // LLVM_LIBC_SHARED_MATH_NEXTDOWNF128_H diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt index ae147c90c5f1b..194c0deb56e3d 100644 --- a/libc/src/__support/math/CMakeLists.txt +++ b/libc/src/__support/math/CMakeLists.txt @@ -4647,7 +4647,7 @@ add_header_library( HDRS nextdownf128.h DEPENDS - libc.include.llvm-libc-types.float128 + libc.src.__support.FPUtil.float128 libc.src.__support.FPUtil.manipulation_functions libc.src.__support.macros.config ) diff --git a/libc/src/__support/math/nextdownf128.h b/libc/src/__support/math/nextdownf128.h index b3a93c3909058..13fb2421935f4 100644 --- a/libc/src/__support/math/nextdownf128.h +++ b/libc/src/__support/math/nextdownf128.h @@ -9,24 +9,21 @@ #ifndef LLVM_LIBC_SRC___SUPPORT_MATH_NEXTDOWNF128_H #define LLVM_LIBC_SRC___SUPPORT_MATH_NEXTDOWNF128_H -#include "include/llvm-libc-types/float128.h" - -#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128 - #include "src/__support/FPUtil/ManipulationFunctions.h" +#include "src/__support/FPUtil/float128.h" #include "src/__support/macros/config.h" namespace LIBC_NAMESPACE_DECL { namespace math { -LIBC_INLINE constexpr float128 nextdownf128(float128 x) { +using LIBC_NAMESPACE::fputil::Float128; + +LIBC_INLINE constexpr Float128 nextdownf128(Float128 x) { return fputil::nextupdown</*IsDown=*/true>(x); } } // namespace math } // namespace LIBC_NAMESPACE_DECL -#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128 - #endif // LLVM_LIBC_SRC___SUPPORT_MATH_NEXTDOWNF128_H diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt index 2b544930c9f71..74f1c859d096b 100644 --- a/libc/src/math/generic/CMakeLists.txt +++ b/libc/src/math/generic/CMakeLists.txt @@ -3353,6 +3353,7 @@ add_entrypoint_object( HDRS ../nextdownf128.h DEPENDS + libc.src.__support.CPP.bit libc.src.__support.math.nextdownf128 ) diff --git a/libc/src/math/generic/nextdownf128.cpp b/libc/src/math/generic/nextdownf128.cpp index 3a9a60fe7130a..087bdb984677e 100644 --- a/libc/src/math/generic/nextdownf128.cpp +++ b/libc/src/math/generic/nextdownf128.cpp @@ -7,12 +7,16 @@ //===----------------------------------------------------------------------===// #include "src/math/nextdownf128.h" +#include "src/__support/CPP/bit.h" #include "src/__support/math/nextdownf128.h" namespace LIBC_NAMESPACE_DECL { +using LIBC_NAMESPACE::fputil::Float128; + LLVM_LIBC_FUNCTION(float128, nextdownf128, (float128 x)) { - return math::nextdownf128(x); + return cpp::bit_cast<float128>( + math::nextdownf128(cpp::bit_cast<Float128>(x))); } } // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/nextdownf128.h b/libc/src/math/nextdownf128.h index 60ba251f67d55..3f9099f084e34 100644 --- a/libc/src/math/nextdownf128.h +++ b/libc/src/math/nextdownf128.h @@ -9,11 +9,16 @@ #ifndef LLVM_LIBC_SRC_MATH_NEXTDOWNF128_H #define LLVM_LIBC_SRC_MATH_NEXTDOWNF128_H +#include "src/__support/FPUtil/float128.h" #include "src/__support/macros/config.h" #include "src/__support/macros/properties/types.h" namespace LIBC_NAMESPACE_DECL { +#ifndef LIBC_TYPES_HAS_NATIVE_FLOAT128 +using float128 = LIBC_NAMESPACE::fputil::Float128; +#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128 + float128 nextdownf128(float128 x); } // namespace LIBC_NAMESPACE_DECL diff --git a/libc/test/shared/shared_math_constexpr_test.cpp b/libc/test/shared/shared_math_constexpr_test.cpp index a4001cdc365d0..af5396b5ee19e 100644 --- a/libc/test/shared/shared_math_constexpr_test.cpp +++ b/libc/test/shared/shared_math_constexpr_test.cpp @@ -381,9 +381,6 @@ static_assert(0 == LIBC_NAMESPACE::shared::isnanl(0.0L)); //===----------------------------------------------------------------------===// static_assert(Float128(0.0) == LIBC_NAMESPACE::shared::ceilf128(Float128(0.0))); -static_assert(float128(0.0) == - LIBC_NAMESPACE::shared::nextafterf128(Float128(0.0), - Float128(0.0))); static_assert(Float128(0.0) == LIBC_NAMESPACE::shared::copysignf128(Float128(0.0), Float128(0.0))); @@ -433,6 +430,9 @@ static_assert(Float128(0.0) == static_assert(Float128(0.0) == LIBC_NAMESPACE::shared::rintf128(Float128(0.0))); static_assert(Float128(0.0) == LIBC_NAMESPACE::shared::roundevenf128(Float128(0.0))); +static_assert(Float128(0.0) == + LIBC_NAMESPACE::shared::nextafterf128(Float128(0.0), + Float128(0.0))); static_assert(Float128(0.0) == LIBC_NAMESPACE::shared::roundf128(Float128(0.0))); static_assert(Float128(0.0) == diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp index e97e1a3c62918..07802e0e30f60 100644 --- a/libc/test/shared/shared_math_test.cpp +++ b/libc/test/shared/shared_math_test.cpp @@ -581,12 +581,12 @@ TEST(LlvmLibcSharedMathTest, AllLongDouble) { // Emulated float128 tests TEST(LlvmLibcSharedMathTest, AllEmuFloat128) { + using FPBits = LIBC_NAMESPACE::fputil::FPBits<Float128>; + Float128 neg_min_denormal = FPBits::min_subnormal(Sign::NEG).get_val(); + Float128 min_denormal = FPBits::min_subnormal(Sign ::POS).get_val(); EXPECT_FP_EQ(Float128(0.0), LIBC_NAMESPACE::shared::atan2f128(Float128(0.0), Float128(0.0))); EXPECT_FP_EQ(Float128(0.0), LIBC_NAMESPACE::shared::ceilf128(Float128(0.0))); - EXPECT_FP_EQ(min_denormal, LIBC_NAMESPACE::shared::nextupf128(Float128(0.0))); - EXPECT_FP_EQ(float128(0.0), LIBC_NAMESPACE::shared::nextafterf128( - Float128(0.0), Float128(0.0))); EXPECT_FP_EQ(Float128(0.0), LIBC_NAMESPACE::shared::copysignf128( Float128(0.0), Float128(0.0))); EXPECT_FP_EQ(Float128(0.0), LIBC_NAMESPACE::shared::fabsf128(Float128(0.0))); @@ -622,6 +622,11 @@ TEST(LlvmLibcSharedMathTest, AllEmuFloat128) { EXPECT_EQ(0L, LIBC_NAMESPACE::shared::lroundf128(Float128(0.0))); EXPECT_FP_EQ(Float128(0.0), LIBC_NAMESPACE::shared::nearbyintf128(Float128(0.0))); + EXPECT_FP_EQ(Float128(0.0), LIBC_NAMESPACE::shared::nextafterf128( + Float128(0.0), Float128(0.0))); + EXPECT_FP_EQ(neg_min_denormal, + LIBC_NAMESPACE::shared::nextdownf128(Float128(0.0))); + EXPECT_FP_EQ(min_denormal, LIBC_NAMESPACE::shared::nextupf128(Float128(0.0))); EXPECT_FP_EQ(Float128(0.0), LIBC_NAMESPACE::shared::rintf128(Float128(0.0))); EXPECT_FP_EQ(Float128(0.0), LIBC_NAMESPACE::shared::roundevenf128(Float128(0.0))); @@ -699,8 +704,6 @@ TEST(LlvmLibcSharedMathTest, AllFloat128) { EXPECT_FP_EQ(float128(0.0), setpayloadsigf128_res); float128 neg_min_denormal = FPBits::min_subnormal(Sign::NEG).get_val(); - EXPECT_FP_EQ(neg_min_denormal, - LIBC_NAMESPACE::shared::nextdownf128(float128(0.0))); float128 min_denormal = FPBits::min_subnormal(Sign ::POS).get_val(); #ifdef LIBC_TYPES_HAS_FLOAT16 diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt index 634f4cefa9aeb..02c3f31c38ae8 100644 --- a/libc/test/src/math/smoke/CMakeLists.txt +++ b/libc/test/src/math/smoke/CMakeLists.txt @@ -4274,6 +4274,7 @@ add_fp_unittest( HDRS NextDownTest.h DEPENDS + libc.src.__support.FPUtil.float128 libc.src.math.nextdownf128 ) diff --git a/libc/test/src/math/smoke/nextdownf128_test.cpp b/libc/test/src/math/smoke/nextdownf128_test.cpp index 932a8b36a59e4..603b31a9f05cc 100644 --- a/libc/test/src/math/smoke/nextdownf128_test.cpp +++ b/libc/test/src/math/smoke/nextdownf128_test.cpp @@ -7,7 +7,12 @@ //===----------------------------------------------------------------------===// #include "NextDownTest.h" +#include "src/__support/FPUtil/float128.h" #include "src/math/nextdownf128.h" +#ifndef LIBC_TYPES_HAS_NATIVE_FLOAT128 +using float128 = LIBC_NAMESPACE::fputil::Float128; +#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128 + LIST_NEXTDOWN_TESTS(float128, LIBC_NAMESPACE::nextdownf128) diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel index 1491c6ef33f49..73ec1c0146c82 100644 --- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel @@ -8543,10 +8543,10 @@ libc_support_library( name = "__support_math_nextdownf128", hdrs = ["src/__support/math/nextdownf128.h"], deps = [ + ":__support_fputil_float128", ":__support_fputil_manipulation_functions", ":__support_macros_config", ":__support_macros_properties_types", - ":llvm_libc_types_float128", ], ) @@ -13143,6 +13143,8 @@ libc_math_function( libc_math_function( name = "nextdownf128", additional_deps = [ + ":__support_cpp_bit", + ":__support_fputil_float128", ":__support_math_nextdownf128", ], ) diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel index abbb48380b528..8c47fb7858e49 100644 --- a/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel @@ -1333,6 +1333,9 @@ math_test( math_test( name = "nextdownf128", hdrs = ["NextDownTest.h"], + deps = [ + "//libc:__support_fputil_float128", + ], ) math_test( >From 57ab737651ffd71f6c5df7e7e4fd21f216ea1877 Mon Sep 17 00:00:00 2001 From: Sukumarsawant <[email protected]> Date: Fri, 21 Aug 2026 16:58:09 +0530 Subject: [PATCH 4/4] cast --- libc/test/src/math/NextAfterTest.h | 36 +++++++++++++++--------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/libc/test/src/math/NextAfterTest.h b/libc/test/src/math/NextAfterTest.h index 82d5378ec3533..01c6ce496aadd 100644 --- a/libc/test/src/math/NextAfterTest.h +++ b/libc/test/src/math/NextAfterTest.h @@ -40,8 +40,8 @@ class NextAfterTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest { typedef T (*NextAfterFunc)(T, T); void testNaN(NextAfterFunc func) { - ASSERT_FP_EQ(func(nan, 0), nan); - ASSERT_FP_EQ(func(0, nan), nan); + ASSERT_FP_EQ(func(nan, zero), nan); + ASSERT_FP_EQ(func(zero, nan), nan); } void testBoundaries(NextAfterFunc func) { @@ -61,57 +61,57 @@ class NextAfterTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest { ASSERT_FP_EQ(result, expected); x = neg_zero; - result = func(x, 1); + result = func(x, T(1)); expected_bits = 1; expected = LIBC_NAMESPACE::cpp::bit_cast<T>(expected_bits); ASSERT_FP_EQ(result, expected); - result = func(x, -1); + result = func(x, T(-1)); expected_bits = FPBits::SIGN_MASK + 1; expected = LIBC_NAMESPACE::cpp::bit_cast<T>(expected_bits); ASSERT_FP_EQ(result, expected); // 'from' is max subnormal value. x = LIBC_NAMESPACE::cpp::bit_cast<T>(max_subnormal); - result = func(x, 1); + result = func(x, T(1)); expected = LIBC_NAMESPACE::cpp::bit_cast<T>(min_normal); ASSERT_FP_EQ(result, expected); - result = func(x, 0); + result = func(x, zero); expected_bits = max_subnormal - 1; expected = LIBC_NAMESPACE::cpp::bit_cast<T>(expected_bits); ASSERT_FP_EQ(result, expected); x = -x; - result = func(x, -1); + result = func(x, T(-1)); expected_bits = FPBits::SIGN_MASK + min_normal; expected = LIBC_NAMESPACE::cpp::bit_cast<T>(expected_bits); ASSERT_FP_EQ(result, expected); - result = func(x, 0); + result = func(x, zero); expected_bits = FPBits::SIGN_MASK + max_subnormal - 1; expected = LIBC_NAMESPACE::cpp::bit_cast<T>(expected_bits); ASSERT_FP_EQ(result, expected); // 'from' is min subnormal value. x = LIBC_NAMESPACE::cpp::bit_cast<T>(min_subnormal); - result = func(x, 1); + result = func(x, T(1)); expected_bits = min_subnormal + 1; expected = LIBC_NAMESPACE::cpp::bit_cast<T>(expected_bits); ASSERT_FP_EQ(result, expected); - ASSERT_FP_EQ(func(x, 0), zero); + ASSERT_FP_EQ(func(x, zero), zero); x = -x; - result = func(x, -1); + result = func(x, T(-1)); expected_bits = FPBits::SIGN_MASK + min_subnormal + 1; expected = LIBC_NAMESPACE::cpp::bit_cast<T>(expected_bits); ASSERT_FP_EQ(result, expected); - ASSERT_FP_EQ(func(x, 0), T(-0.0)); + ASSERT_FP_EQ(func(x, zero), T(-0.0)); // 'from' is min normal. x = LIBC_NAMESPACE::cpp::bit_cast<T>(min_normal); - result = func(x, 0); + result = func(x, zero); expected_bits = max_subnormal; expected = LIBC_NAMESPACE::cpp::bit_cast<T>(expected_bits); ASSERT_FP_EQ(result, expected); @@ -122,7 +122,7 @@ class NextAfterTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest { ASSERT_FP_EQ(result, expected); x = -x; - result = func(x, 0); + result = func(x, zero); expected_bits = FPBits::SIGN_MASK + max_subnormal; expected = LIBC_NAMESPACE::cpp::bit_cast<T>(expected_bits); ASSERT_FP_EQ(result, expected); @@ -142,14 +142,14 @@ class NextAfterTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest { // 'from' is infinity. x = inf; - result = func(x, 0); + result = func(x, zero); expected_bits = max_normal; expected = LIBC_NAMESPACE::cpp::bit_cast<T>(expected_bits); ASSERT_FP_EQ(result, expected); ASSERT_FP_EQ(func(x, inf), inf); x = neg_inf; - result = func(x, 0); + result = func(x, zero); expected_bits = FPBits::SIGN_MASK + max_normal; expected = LIBC_NAMESPACE::cpp::bit_cast<T>(expected_bits); ASSERT_FP_EQ(result, expected); @@ -157,7 +157,7 @@ class NextAfterTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest { // 'from' is a power of 2. x = T(32.0); - result = func(x, 0); + result = func(x, zero); FPBits x_bits = FPBits(x); FPBits result_bits = FPBits(result); ASSERT_EQ(result_bits.get_biased_exponent(), @@ -172,7 +172,7 @@ class NextAfterTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest { x = -x; - result = func(x, 0); + result = func(x, zero); result_bits = FPBits(result); ASSERT_EQ(result_bits.get_biased_exponent(), uint16_t(x_bits.get_biased_exponent() - 1)); _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
