Skip to content

Commit 11cc8aa

Browse files
committed
fix: NO FMA build
Signed-off-by: Krishna Pandey <[email protected]>
1 parent 0979c7a commit 11cc8aa

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

libc/src/math/generic/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2250,6 +2250,7 @@ add_entrypoint_object(
22502250
libc.src.__support.FPUtil.multiply_add
22512251
libc.src.__support.FPUtil.polyeval
22522252
libc.src.__support.macros.optimization
2253+
libc.src.__support.macros.properties.cpu_features
22532254
)
22542255

22552256
add_entrypoint_object(

libc/src/math/generic/log_bf16.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "src/__support/common.h"
1515
#include "src/__support/macros/config.h"
1616
#include "src/__support/macros/optimization.h"
17+
#include "src/__support/macros/properties/cpu_features.h"
1718

1819
namespace LIBC_NAMESPACE_DECL {
1920

@@ -99,6 +100,13 @@ LLVM_LIBC_FUNCTION(bfloat16, log_bf16, (bfloat16 x)) {
99100
return FPBits::inf().get_val();
100101
}
101102

103+
#ifndef LIBC_TARGET_CPU_HAS_FMA
104+
// log(0.00000000000000171390679426508540927898138761520386)
105+
// ~= -34.00000095
106+
if (LIBC_UNLIKELY(x_u == 0x26F7U))
107+
return bfloat16(-34.0000009);
108+
#endif // LIBC_TARGET_CPU_HAS_FMA
109+
102110
int e = -FPBits::EXP_BIAS;
103111

104112
// When x is subnormal, normalize it.

0 commit comments

Comments
 (0)