Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion libc/shared/math/expf.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

#include "shared/libc_common.h"
#include "src/__support/math/expf.h"
#include "src/__support/math/expf_static_rounding.h"

namespace LIBC_NAMESPACE_DECL {
namespace shared {
Expand Down
43 changes: 0 additions & 43 deletions libc/src/__support/math/expf_static_rounding.h

This file was deleted.

5 changes: 0 additions & 5 deletions llvm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -657,11 +657,6 @@ endif()

set(LLVM_ENABLE_Z3_SOLVER_DEFAULT "${Z3_FOUND}")

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


if( LLVM_TARGETS_TO_BUILD STREQUAL "all" )
set( LLVM_TARGETS_TO_BUILD ${LLVM_ALL_TARGETS} )
Expand Down
6 changes: 0 additions & 6 deletions llvm/include/llvm/ADT/APFloat.h
Original file line number Diff line number Diff line change
Expand Up @@ -1493,8 +1493,6 @@ class APFloat : public APFloatBase {
friend APFloat frexp(const APFloat &X, int &Exp, roundingMode RM);
friend IEEEFloat;
friend DoubleAPFloat;

friend APFloat exp(const APFloat &X, roundingMode RM);
};

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

/// Implement IEEE 754-2019 exp functions.
LLVM_READONLY
APFloat exp(const APFloat &X, RoundingMode RM = APFloat::rmNearestTiesToEven);

inline raw_ostream &operator<<(raw_ostream &OS, const APFloat &V) {
V.print(OS);
return OS;
Expand Down
26 changes: 0 additions & 26 deletions llvm/lib/Support/APFloat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@
#include <cstring>
#include <limits.h>

// Shared headers from LLVM libc
#include "shared/math.h"

#define APFLOAT_DISPATCH_ON_SEMANTICS(METHOD_CALL) \
do { \
if (usesLayout<IEEEFloat>(getSemantics())) \
Expand Down Expand Up @@ -6158,29 +6155,6 @@ float APFloat::convertToFloat() const {
return Temp.getIEEE().convertToFloat();
}

static constexpr int getFEnvRoundingMode(llvm::RoundingMode rm) {
switch (rm) {
case APFloat::rmTowardPositive:
return FE_UPWARD;
case APFloat::rmTowardNegative:
return FE_DOWNWARD;
case APFloat::rmTowardZero:
return FE_TOWARDZERO;
default:
// TODO: fix rmNearestTiesToAway for platform without FE_TONEARESTFROMZERO.
return FE_TONEAREST;
};
}

APFloat exp(const APFloat &X, RoundingMode rounding_mode) {
if (&X.getSemantics() == &APFloat::IEEEsingle()) {
float result = LIBC_NAMESPACE::shared::expf(
X.convertToFloat(), getFEnvRoundingMode(rounding_mode));
return APFloat(result);
}
llvm_unreachable("Unsupported floating-point semantics");
}

APFloat::Storage::~Storage() {
if (usesLayout<IEEEFloat>(*semantics)) {
IEEE.~IEEEFloat();
Expand Down
6 changes: 0 additions & 6 deletions llvm/lib/Support/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -395,9 +395,3 @@ target_include_directories(LLVMSupport
PRIVATE
${LLVM_THIRD_PARTY_DIR}/siphash/include
)

# Integrating LLVM libc's math functions
target_include_directories(LLVMSupport PRIVATE "${LLVM_SOURCE_DIR}/../libc")
if(NOT MSVC)
target_compile_options(LLVMSupport PRIVATE "-Wno-c99-extensions") # _Complex warnings.
endif()
2 changes: 1 addition & 1 deletion llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1531,7 +1531,7 @@ bool AMDGPULibCalls::evaluateScalarMathFunc(const FuncInfo &FInfo, double &Res0,
return true;

case AMDGPULibFunc::EI_EXP:
Res0 = std::exp(opr0);
Res0 = exp(opr0);
return true;

case AMDGPULibFunc::EI_EXP2:
Expand Down
74 changes: 0 additions & 74 deletions llvm/unittests/ADT/APFloatTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10182,78 +10182,4 @@ TEST(APFloatTest, FrexpQuietSNaN) {
EXPECT_FALSE(Result.isSignaling());
}

TEST(APFloatTest, expf) {
std::array<llvm::RoundingMode, 4> allRoundingModes = {
APFloat::rmNearestTiesToEven, APFloat::rmTowardPositive,
APFloat::rmTowardNegative, APFloat::rmTowardZero};
for (auto rm : allRoundingModes) {
// exp(+-0) = 1 for all rounding modes.
EXPECT_EQ(1.0f, llvm::exp(APFloat(0.0f), rm).convertToFloat());
EXPECT_EQ(1.0f, llvm::exp(APFloat(-0.0f), rm).convertToFloat());
// exp(+Inf) = +Inf for all rounding modes.
EXPECT_EQ(std::numeric_limits<float>::infinity(),
llvm::exp(APFloat::getInf(APFloat::IEEEsingle(), false), rm)
.convertToFloat());
// exp(-Inf) = 0 for all rounding modes.
EXPECT_EQ(0.0f, llvm::exp(APFloat::getInf(APFloat::IEEEsingle(), true), rm)
.convertToFloat());
// exp(NaN) = NaN for all rounding modes.
EXPECT_TRUE(llvm::exp(APFloat::getNaN(APFloat::IEEEsingle()), rm).isNaN());
}
// exp(1)
EXPECT_EQ(
0x1.5bf0a8p1f,
llvm::exp(APFloat(1.0f), APFloat::rmNearestTiesToEven).convertToFloat());
EXPECT_EQ(
0x1.5bf0aap1f,
llvm::exp(APFloat(1.0f), APFloat::rmTowardPositive).convertToFloat());
EXPECT_EQ(
0x1.5bf0a8p1f,
llvm::exp(APFloat(1.0f), APFloat::rmTowardNegative).convertToFloat());
EXPECT_EQ(0x1.5bf0a8p1f,
llvm::exp(APFloat(1.0f), APFloat::rmTowardZero).convertToFloat());
// exp(float max)
EXPECT_EQ(std::numeric_limits<float>::infinity(),
llvm::exp(APFloat::getLargest(APFloat::IEEEsingle(), false),
APFloat::rmNearestTiesToEven)
.convertToFloat());
EXPECT_EQ(std::numeric_limits<float>::infinity(),
llvm::exp(APFloat::getLargest(APFloat::IEEEsingle(), false),
APFloat::rmTowardPositive)
.convertToFloat());
EXPECT_EQ(std::numeric_limits<float>::max(),
llvm::exp(APFloat::getLargest(APFloat::IEEEsingle(), false),
APFloat::rmTowardNegative)
.convertToFloat());
EXPECT_EQ(std::numeric_limits<float>::max(),
llvm::exp(APFloat::getLargest(APFloat::IEEEsingle(), false),
APFloat::rmTowardZero)
.convertToFloat());
// exp(min_denormal)
EXPECT_EQ(1.0f, llvm::exp(APFloat::getSmallest(APFloat::IEEEsingle(), false),
APFloat::rmNearestTiesToEven)
.convertToFloat());
EXPECT_EQ(0x1.000002p0f,
llvm::exp(APFloat::getSmallest(APFloat::IEEEsingle(), false),
APFloat::rmTowardPositive)
.convertToFloat());
EXPECT_EQ(1.0f, llvm::exp(APFloat::getSmallest(APFloat::IEEEsingle(), false),
APFloat::rmTowardNegative)
.convertToFloat());
EXPECT_EQ(1.0f, llvm::exp(APFloat::getSmallest(APFloat::IEEEsingle(), false),
APFloat::rmTowardZero)
.convertToFloat());
// Default rounding mode.
// exp(-1)
EXPECT_EQ(0x1.78b564p-2f, llvm::exp(APFloat(-1.0f)).convertToFloat());
EXPECT_EQ(
0x1.78b564p-2f,
llvm::exp(APFloat(-1.0f), APFloat::rmTowardPositive).convertToFloat());
EXPECT_EQ(
0x1.78b562p-2f,
llvm::exp(APFloat(-1.0f), APFloat::rmTowardNegative).convertToFloat());
EXPECT_EQ(0x1.78b562p-2f,
llvm::exp(APFloat(-1.0f), APFloat::rmTowardZero).convertToFloat());
}

} // namespace
Loading