Skip to content

Commit efd9dc8

Browse files
authored
Revert "[APFloat] Add exp function for APFloat::IEEESsingle using expf implementation from LLVM libc. (#143959)" (#172325)
This reverts commit 4190d57. See https://lab.llvm.org/buildbot/#/builders/181/builds/33524 ``` from /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/llvm/lib/Support/APFloat.cpp:32: /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/llvm/../libc/src/__support/math/asin_utils.h:548:1: in ‘constexpr’ expansion of ‘__llvm_libc::fputil::DyadicFloat<128>(__llvm_libc::Sign::POS, -127, __llvm_libc::BigInt<128, false, long unsigned int>(__llvm_libc::operator""_u128(((const char*)"0x80000000\'00000000\'00000000\'00000000"))))’ /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/llvm/../libc/src/__support/FPUtil/dyadic_float.h:109:5: in ‘constexpr’ expansion of ‘((__llvm_libc::fputil::DyadicFloat<128>*)this)->__llvm_libc::fputil::DyadicFloat<128>::normalize()’ /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/llvm/../libc/src/__support/FPUtil/dyadic_float.h:118:16: in ‘constexpr’ expansion of ‘((__llvm_libc::fputil::DyadicFloat<128>*)this)->__llvm_libc::fputil::DyadicFloat<128>::mantissa.__llvm_libc::BigInt<128, false, long unsigned int>::operator<<=(((size_t)shift_length))’ /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/llvm/../libc/src/__support/big_int.h:829:52: in ‘constexpr’ expansion of ‘__llvm_libc::multiword::shift<__llvm_libc::multiword::LEFT, false, long unsigned int, 2>(((__llvm_libc::BigInt<128, false, long unsigned int>*)this)->__llvm_libc::BigInt<128, false, long unsigned int>::val, s)’ /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/llvm/../libc/src/__support/big_int.h:264:35: error: ‘constexpr __llvm_libc::cpp::enable_if_t<((((sizeof (To) == sizeof (From)) && __llvm_libc::cpp::is_trivially_constructible<To>::value) && __llvm_libc::cpp::is_trivially_copyable<T>::value) && __llvm_libc::cpp::is_trivially_copyable<From>::value), To> __llvm_libc::cpp::bit_cast(const From&) [with To = __int128 unsigned; From = __llvm_libc::cpp::array<long unsigned int, 2>; __llvm_libc::cpp::enable_if_t<((((sizeof (To) == sizeof (From)) && __llvm_libc::cpp::is_trivially_constructible<To>::value) && __llvm_libc::cpp::is_trivially_copyable<T>::value) && __llvm_libc::cpp::is_trivially_copyable<From>::value), To> = __int128 unsigned]’ called in a constant expression 264 | auto tmp = cpp::bit_cast<type>(array); | ~~~~~~~~~~~~~~~~~~~^~~~~~~ from /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/llvm/lib/Support/APFloat.cpp:32: /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/llvm/../libc/src/__support/CPP/bit.h:48:1: note: ‘constexpr __llvm_libc::cpp::enable_if_t<((((sizeof (To) == sizeof (From)) && __llvm_libc::cpp::is_trivially_constructible<To>::value) && __llvm_libc::cpp::is_trivially_copyable<T>::value) && __llvm_libc::cpp::is_trivially_copyable<From>::value), To> __llvm_libc::cpp::bit_cast(const From&) [with To = __int128 unsigned; From = __llvm_libc::cpp::array<long unsigned int, 2>; __llvm_libc::cpp::enable_if_t<((((sizeof (To) == sizeof (From)) && __llvm_libc::cpp::is_trivially_constructible<To>::value) && __llvm_libc::cpp::is_trivially_copyable<T>::value) && __llvm_libc::cpp::is_trivially_copyable<From>::value), To> = __int128 unsigned]’ is not usable as a ‘constexpr’ function because: 48 | bit_cast(const From &from) { | ^~~~~~~~ /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/llvm/../libc/src/__support/CPP/bit.h:56:28: error: call to non-‘constexpr’ function ‘void __llvm_libc::cpp::inline_copy(const char*, char*) [with unsigned int N = 16]’ 56 | inline_copy<sizeof(From)>(src, dst); ```
1 parent f0c9acc commit efd9dc8

File tree

8 files changed

+1
-162
lines changed

8 files changed

+1
-162
lines changed

libc/shared/math/expf.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
#include "shared/libc_common.h"
1313
#include "src/__support/math/expf.h"
14-
#include "src/__support/math/expf_static_rounding.h"
1514

1615
namespace LIBC_NAMESPACE_DECL {
1716
namespace shared {

libc/src/__support/math/expf_static_rounding.h

Lines changed: 0 additions & 43 deletions
This file was deleted.

llvm/CMakeLists.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -657,11 +657,6 @@ endif()
657657

658658
set(LLVM_ENABLE_Z3_SOLVER_DEFAULT "${Z3_FOUND}")
659659

660-
include(FindLibcCommonUtils)
661-
if(NOT TARGET llvm-libc-common-utilities)
662-
message(FATAL_ERROR "LLVM libc is not found at ${libc_path}.")
663-
endif()
664-
665660

666661
if( LLVM_TARGETS_TO_BUILD STREQUAL "all" )
667662
set( LLVM_TARGETS_TO_BUILD ${LLVM_ALL_TARGETS} )

llvm/include/llvm/ADT/APFloat.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1493,8 +1493,6 @@ class APFloat : public APFloatBase {
14931493
friend APFloat frexp(const APFloat &X, int &Exp, roundingMode RM);
14941494
friend IEEEFloat;
14951495
friend DoubleAPFloat;
1496-
1497-
friend APFloat exp(const APFloat &X, roundingMode RM);
14981496
};
14991497

15001498
static_assert(sizeof(APFloat) == sizeof(detail::IEEEFloat),
@@ -1647,10 +1645,6 @@ inline APFloat maximumnum(const APFloat &A, const APFloat &B) {
16471645
return A < B ? B : A;
16481646
}
16491647

1650-
/// Implement IEEE 754-2019 exp functions.
1651-
LLVM_READONLY
1652-
APFloat exp(const APFloat &X, RoundingMode RM = APFloat::rmNearestTiesToEven);
1653-
16541648
inline raw_ostream &operator<<(raw_ostream &OS, const APFloat &V) {
16551649
V.print(OS);
16561650
return OS;

llvm/lib/Support/APFloat.cpp

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@
2828
#include <cstring>
2929
#include <limits.h>
3030

31-
// Shared headers from LLVM libc
32-
#include "shared/math.h"
33-
3431
#define APFLOAT_DISPATCH_ON_SEMANTICS(METHOD_CALL) \
3532
do { \
3633
if (usesLayout<IEEEFloat>(getSemantics())) \
@@ -6158,29 +6155,6 @@ float APFloat::convertToFloat() const {
61586155
return Temp.getIEEE().convertToFloat();
61596156
}
61606157

6161-
static constexpr int getFEnvRoundingMode(llvm::RoundingMode rm) {
6162-
switch (rm) {
6163-
case APFloat::rmTowardPositive:
6164-
return FE_UPWARD;
6165-
case APFloat::rmTowardNegative:
6166-
return FE_DOWNWARD;
6167-
case APFloat::rmTowardZero:
6168-
return FE_TOWARDZERO;
6169-
default:
6170-
// TODO: fix rmNearestTiesToAway for platform without FE_TONEARESTFROMZERO.
6171-
return FE_TONEAREST;
6172-
};
6173-
}
6174-
6175-
APFloat exp(const APFloat &X, RoundingMode rounding_mode) {
6176-
if (&X.getSemantics() == &APFloat::IEEEsingle()) {
6177-
float result = LIBC_NAMESPACE::shared::expf(
6178-
X.convertToFloat(), getFEnvRoundingMode(rounding_mode));
6179-
return APFloat(result);
6180-
}
6181-
llvm_unreachable("Unsupported floating-point semantics");
6182-
}
6183-
61846158
APFloat::Storage::~Storage() {
61856159
if (usesLayout<IEEEFloat>(*semantics)) {
61866160
IEEE.~IEEEFloat();

llvm/lib/Support/CMakeLists.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -395,9 +395,3 @@ target_include_directories(LLVMSupport
395395
PRIVATE
396396
${LLVM_THIRD_PARTY_DIR}/siphash/include
397397
)
398-
399-
# Integrating LLVM libc's math functions
400-
target_include_directories(LLVMSupport PRIVATE "${LLVM_SOURCE_DIR}/../libc")
401-
if(NOT MSVC)
402-
target_compile_options(LLVMSupport PRIVATE "-Wno-c99-extensions") # _Complex warnings.
403-
endif()

llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1531,7 +1531,7 @@ bool AMDGPULibCalls::evaluateScalarMathFunc(const FuncInfo &FInfo, double &Res0,
15311531
return true;
15321532

15331533
case AMDGPULibFunc::EI_EXP:
1534-
Res0 = std::exp(opr0);
1534+
Res0 = exp(opr0);
15351535
return true;
15361536

15371537
case AMDGPULibFunc::EI_EXP2:

llvm/unittests/ADT/APFloatTest.cpp

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -10182,78 +10182,4 @@ TEST(APFloatTest, FrexpQuietSNaN) {
1018210182
EXPECT_FALSE(Result.isSignaling());
1018310183
}
1018410184

10185-
TEST(APFloatTest, expf) {
10186-
std::array<llvm::RoundingMode, 4> allRoundingModes = {
10187-
APFloat::rmNearestTiesToEven, APFloat::rmTowardPositive,
10188-
APFloat::rmTowardNegative, APFloat::rmTowardZero};
10189-
for (auto rm : allRoundingModes) {
10190-
// exp(+-0) = 1 for all rounding modes.
10191-
EXPECT_EQ(1.0f, llvm::exp(APFloat(0.0f), rm).convertToFloat());
10192-
EXPECT_EQ(1.0f, llvm::exp(APFloat(-0.0f), rm).convertToFloat());
10193-
// exp(+Inf) = +Inf for all rounding modes.
10194-
EXPECT_EQ(std::numeric_limits<float>::infinity(),
10195-
llvm::exp(APFloat::getInf(APFloat::IEEEsingle(), false), rm)
10196-
.convertToFloat());
10197-
// exp(-Inf) = 0 for all rounding modes.
10198-
EXPECT_EQ(0.0f, llvm::exp(APFloat::getInf(APFloat::IEEEsingle(), true), rm)
10199-
.convertToFloat());
10200-
// exp(NaN) = NaN for all rounding modes.
10201-
EXPECT_TRUE(llvm::exp(APFloat::getNaN(APFloat::IEEEsingle()), rm).isNaN());
10202-
}
10203-
// exp(1)
10204-
EXPECT_EQ(
10205-
0x1.5bf0a8p1f,
10206-
llvm::exp(APFloat(1.0f), APFloat::rmNearestTiesToEven).convertToFloat());
10207-
EXPECT_EQ(
10208-
0x1.5bf0aap1f,
10209-
llvm::exp(APFloat(1.0f), APFloat::rmTowardPositive).convertToFloat());
10210-
EXPECT_EQ(
10211-
0x1.5bf0a8p1f,
10212-
llvm::exp(APFloat(1.0f), APFloat::rmTowardNegative).convertToFloat());
10213-
EXPECT_EQ(0x1.5bf0a8p1f,
10214-
llvm::exp(APFloat(1.0f), APFloat::rmTowardZero).convertToFloat());
10215-
// exp(float max)
10216-
EXPECT_EQ(std::numeric_limits<float>::infinity(),
10217-
llvm::exp(APFloat::getLargest(APFloat::IEEEsingle(), false),
10218-
APFloat::rmNearestTiesToEven)
10219-
.convertToFloat());
10220-
EXPECT_EQ(std::numeric_limits<float>::infinity(),
10221-
llvm::exp(APFloat::getLargest(APFloat::IEEEsingle(), false),
10222-
APFloat::rmTowardPositive)
10223-
.convertToFloat());
10224-
EXPECT_EQ(std::numeric_limits<float>::max(),
10225-
llvm::exp(APFloat::getLargest(APFloat::IEEEsingle(), false),
10226-
APFloat::rmTowardNegative)
10227-
.convertToFloat());
10228-
EXPECT_EQ(std::numeric_limits<float>::max(),
10229-
llvm::exp(APFloat::getLargest(APFloat::IEEEsingle(), false),
10230-
APFloat::rmTowardZero)
10231-
.convertToFloat());
10232-
// exp(min_denormal)
10233-
EXPECT_EQ(1.0f, llvm::exp(APFloat::getSmallest(APFloat::IEEEsingle(), false),
10234-
APFloat::rmNearestTiesToEven)
10235-
.convertToFloat());
10236-
EXPECT_EQ(0x1.000002p0f,
10237-
llvm::exp(APFloat::getSmallest(APFloat::IEEEsingle(), false),
10238-
APFloat::rmTowardPositive)
10239-
.convertToFloat());
10240-
EXPECT_EQ(1.0f, llvm::exp(APFloat::getSmallest(APFloat::IEEEsingle(), false),
10241-
APFloat::rmTowardNegative)
10242-
.convertToFloat());
10243-
EXPECT_EQ(1.0f, llvm::exp(APFloat::getSmallest(APFloat::IEEEsingle(), false),
10244-
APFloat::rmTowardZero)
10245-
.convertToFloat());
10246-
// Default rounding mode.
10247-
// exp(-1)
10248-
EXPECT_EQ(0x1.78b564p-2f, llvm::exp(APFloat(-1.0f)).convertToFloat());
10249-
EXPECT_EQ(
10250-
0x1.78b564p-2f,
10251-
llvm::exp(APFloat(-1.0f), APFloat::rmTowardPositive).convertToFloat());
10252-
EXPECT_EQ(
10253-
0x1.78b562p-2f,
10254-
llvm::exp(APFloat(-1.0f), APFloat::rmTowardNegative).convertToFloat());
10255-
EXPECT_EQ(0x1.78b562p-2f,
10256-
llvm::exp(APFloat(-1.0f), APFloat::rmTowardZero).convertToFloat());
10257-
}
10258-
1025910185
} // namespace

0 commit comments

Comments
 (0)