Skip to content

Commit 49cb38c

Browse files
committed
- Addressed the comments and added entrypoints to other targets in Linux
1 parent 7cb3fb1 commit 49cb38c

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

libc/config/linux/aarch64/entrypoints.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
735735
libc.src.math.rintf16
736736
libc.src.math.roundevenf16
737737
libc.src.math.roundf16
738+
libc.src.math.rsqrtf16
738739
libc.src.math.scalblnf16
739740
libc.src.math.scalbnf16
740741
libc.src.math.setpayloadf16

libc/config/linux/riscv/entrypoints.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
749749
libc.src.math.rintf16
750750
libc.src.math.roundevenf16
751751
libc.src.math.roundf16
752+
libc.src.math.rsqrtf16
752753
libc.src.math.scalblnf16
753754
libc.src.math.scalbnf16
754755
libc.src.math.setpayloadf16

libc/src/__support/math/rsqrtf16.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
namespace LIBC_NAMESPACE_DECL {
2525
namespace math {
2626

27-
static constexpr float16 rsqrtf16(float16 x) {
27+
LIBC_INLINE static constexpr float16 rsqrtf16(float16 x) {
2828
using FPBits = fputil::FPBits<float16>;
2929
FPBits xbits(x);
3030

@@ -56,9 +56,8 @@ static constexpr float16 rsqrtf16(float16 x) {
5656
}
5757

5858
// x = +inf => rsqrt(x) = 0
59-
if (LIBC_UNLIKELY(xbits.is_inf())) {
59+
if (LIBC_UNLIKELY(xbits.is_inf()))
6060
return FPBits::zero().get_val();
61-
}
6261

6362
// TODO: add integer based implementation when LIBC_TARGET_CPU_HAS_FPU_FLOAT
6463
// is not defined
@@ -67,9 +66,9 @@ static constexpr float16 rsqrtf16(float16 x) {
6766
// Targeted post-corrections to ensure correct rounding in half for specific
6867
// mantissa patterns
6968
const uint16_t half_mantissa = x_abs & 0x3ff;
70-
if (half_mantissa == 0x011F) {
69+
if (LIBC_UNLIKELY(half_mantissa == 0x011F)) {
7170
result = fputil::multiply_add(result, 0x1.0p-21f, result);
72-
} else if (half_mantissa == 0x0313) {
71+
} else if (LIBC_UNLIKELY(half_mantissa == 0x0313)) {
7372
result = fputil::multiply_add(result, -0x1.0p-21f, result);
7473
}
7574

0 commit comments

Comments
 (0)