Skip to content

[libc][math][c23] Add remaining linux/* entrypoints for {,u}fromfp{,x}* #86692

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

overmighty
Copy link
Member

I haven't tested on these targets and will rely on the buildbots.

cc @lntue

@llvmbot llvmbot added the libc label Mar 26, 2024
@llvmbot
Copy link
Member

llvmbot commented Mar 26, 2024

@llvm/pr-subscribers-libc

Author: OverMighty (overmighty)

Changes

I haven't tested on these targets and will rely on the buildbots.

cc @lntue


Full diff: https://github.com/llvm/llvm-project/pull/86692.diff

4 Files Affected:

  • (modified) libc/config/linux/aarch64/entrypoints.txt (+16)
  • (modified) libc/config/linux/arm/entrypoints.txt (+12)
  • (modified) libc/config/linux/riscv/entrypoints.txt (+16)
  • (modified) libc/docs/math/index.rst (+16-16)
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index 78da7f0b334b1f..ab0be7e35dced2 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -396,6 +396,12 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.frexp
     libc.src.math.frexpf
     libc.src.math.frexpl
+    libc.src.math.fromfp
+    libc.src.math.fromfpf
+    libc.src.math.fromfpl
+    libc.src.math.fromfpx
+    libc.src.math.fromfpxf
+    libc.src.math.fromfpxl
     libc.src.math.hypot
     libc.src.math.hypotf
     libc.src.math.ilogb
@@ -478,6 +484,12 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.trunc
     libc.src.math.truncf
     libc.src.math.truncl
+    libc.src.math.ufromfp
+    libc.src.math.ufromfpf
+    libc.src.math.ufromfpl
+    libc.src.math.ufromfpx
+    libc.src.math.ufromfpxf
+    libc.src.math.ufromfpxl
 )
 
 if(LIBC_TYPES_HAS_FLOAT128)
@@ -500,6 +512,8 @@ if(LIBC_TYPES_HAS_FLOAT128)
     libc.src.math.fminimum_mag_numf128
     libc.src.math.fmodf128
     libc.src.math.frexpf128
+    libc.src.math.fromfpf128
+    libc.src.math.fromfpxf128
     libc.src.math.ilogbf128
     libc.src.math.ldexpf128
     libc.src.math.llogbf128
@@ -517,6 +531,8 @@ if(LIBC_TYPES_HAS_FLOAT128)
     libc.src.math.roundf128
     libc.src.math.sqrtf128
     libc.src.math.truncf128
+    libc.src.math.ufromfpf128
+    libc.src.math.ufromfpxf128
   )
 endif()
 
diff --git a/libc/config/linux/arm/entrypoints.txt b/libc/config/linux/arm/entrypoints.txt
index 6e63e270280e7a..1d9d5ed67200c1 100644
--- a/libc/config/linux/arm/entrypoints.txt
+++ b/libc/config/linux/arm/entrypoints.txt
@@ -263,6 +263,12 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.frexp
     libc.src.math.frexpf
     libc.src.math.frexpl
+    libc.src.math.fromfp
+    libc.src.math.fromfpf
+    libc.src.math.fromfpl
+    libc.src.math.fromfpx
+    libc.src.math.fromfpxf
+    libc.src.math.fromfpxl
     libc.src.math.hypot
     libc.src.math.hypotf
     libc.src.math.ilogb
@@ -345,6 +351,12 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.trunc
     libc.src.math.truncf
     libc.src.math.truncl
+    libc.src.math.ufromfp
+    libc.src.math.ufromfpf
+    libc.src.math.ufromfpl
+    libc.src.math.ufromfpx
+    libc.src.math.ufromfpxf
+    libc.src.math.ufromfpxl
 )
 
 set(TARGET_LLVMLIBC_ENTRYPOINTS
diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt
index 5aae4e246cfb3c..96acd999efda4d 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -404,6 +404,12 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.frexp
     libc.src.math.frexpf
     libc.src.math.frexpl
+    libc.src.math.fromfp
+    libc.src.math.fromfpf
+    libc.src.math.fromfpl
+    libc.src.math.fromfpx
+    libc.src.math.fromfpxf
+    libc.src.math.fromfpxl
     libc.src.math.hypot
     libc.src.math.hypotf
     libc.src.math.ilogb
@@ -486,6 +492,12 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.trunc
     libc.src.math.truncf
     libc.src.math.truncl
+    libc.src.math.ufromfp
+    libc.src.math.ufromfpf
+    libc.src.math.ufromfpl
+    libc.src.math.ufromfpx
+    libc.src.math.ufromfpxf
+    libc.src.math.ufromfpxl
 )
 
 if(LIBC_TYPES_HAS_FLOAT128)
@@ -508,6 +520,8 @@ if(LIBC_TYPES_HAS_FLOAT128)
     libc.src.math.fminimum_mag_numf128
     libc.src.math.fmodf128
     libc.src.math.frexpf128
+    libc.src.math.fromfpf128
+    libc.src.math.fromfpxf128
     libc.src.math.ilogbf128
     libc.src.math.ldexpf128
     libc.src.math.llogbf128
@@ -525,6 +539,8 @@ if(LIBC_TYPES_HAS_FLOAT128)
     libc.src.math.roundf128
     libc.src.math.sqrtf128
     libc.src.math.truncf128
+    libc.src.math.ufromfpf128
+    libc.src.math.ufromfpxf128
   )
 endif()
 
diff --git a/libc/docs/math/index.rst b/libc/docs/math/index.rst
index 080b6a4427f511..d8dee3c9061908 100644
--- a/libc/docs/math/index.rst
+++ b/libc/docs/math/index.rst
@@ -190,21 +190,21 @@ Basic Operations
 +------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
 | frexpf128        | |check| | |check| |         | |check| |         |         |         |         |         |         |         |         |
 +------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| fromfp           | |check| |         |         |         |         |         |         |         |         |         |         |         |
+| fromfp           | |check| | |check| | |check| | |check| |         |         |         |         |         |         |         |         |
 +------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| fromfpf          | |check| |         |         |         |         |         |         |         |         |         |         |         |
+| fromfpf          | |check| | |check| | |check| | |check| |         |         |         |         |         |         |         |         |
 +------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| fromfpl          | |check| |         |         |         |         |         |         |         |         |         |         |         |
+| fromfpl          | |check| | |check| | |check| | |check| |         |         |         |         |         |         |         |         |
 +------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| fromfpf128       | |check| |         |         |         |         |         |         |         |         |         |         |         |
+| fromfpf128       | |check| | |check| |         | |check| |         |         |         |         |         |         |         |         |
 +------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| fromfpx          | |check| |         |         |         |         |         |         |         |         |         |         |         |
+| fromfpx          | |check| | |check| | |check| | |check| |         |         |         |         |         |         |         |         |
 +------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| fromfpxf         | |check| |         |         |         |         |         |         |         |         |         |         |         |
+| fromfpxf         | |check| | |check| | |check| | |check| |         |         |         |         |         |         |         |         |
 +------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| fromfpxl         | |check| |         |         |         |         |         |         |         |         |         |         |         |
+| fromfpxl         | |check| | |check| | |check| | |check| |         |         |         |         |         |         |         |         |
 +------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| fromfpxf128      | |check| |         |         |         |         |         |         |         |         |         |         |         |
+| fromfpxf128      | |check| | |check| |         | |check| |         |         |         |         |         |         |         |         |
 +------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
 | ilogb            | |check| | |check| | |check| | |check| | |check| |         |         | |check| | |check| | |check| |         |         |
 +------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
@@ -364,21 +364,21 @@ Basic Operations
 +------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
 | truncf128        | |check| | |check| |         | |check| |         |         |         |         |         |         |         |         |
 +------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| ufromfp          | |check| |         |         |         |         |         |         |         |         |         |         |         |
+| ufromfp          | |check| | |check| | |check| | |check| |         |         |         |         |         |         |         |         |
 +------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| ufromfpf         | |check| |         |         |         |         |         |         |         |         |         |         |         |
+| ufromfpf         | |check| | |check| | |check| | |check| |         |         |         |         |         |         |         |         |
 +------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| ufromfpl         | |check| |         |         |         |         |         |         |         |         |         |         |         |
+| ufromfpl         | |check| | |check| | |check| | |check| |         |         |         |         |         |         |         |         |
 +------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| ufromfpf128      | |check| |         |         |         |         |         |         |         |         |         |         |         |
+| ufromfpf128      | |check| | |check| |         | |check| |         |         |         |         |         |         |         |         |
 +------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| ufromfpx         | |check| |         |         |         |         |         |         |         |         |         |         |         |
+| ufromfpx         | |check| | |check| | |check| | |check| |         |         |         |         |         |         |         |         |
 +------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| ufromfpxf        | |check| |         |         |         |         |         |         |         |         |         |         |         |
+| ufromfpxf        | |check| | |check| | |check| | |check| |         |         |         |         |         |         |         |         |
 +------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| ufromfpxl        | |check| |         |         |         |         |         |         |         |         |         |         |         |
+| ufromfpxl        | |check| | |check| | |check| | |check| |         |         |         |         |         |         |         |         |
 +------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| ufromfpxf128     | |check| |         |         |         |         |         |         |         |         |         |         |         |
+| ufromfpxf128     | |check| | |check| |         | |check| |         |         |         |         |         |         |         |         |
 +------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
 
 

Copy link
Member

@nickdesaulniers nickdesaulniers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, you'll just want to keep an eye on the buildbots after this lands.

https://lab.llvm.org/buildbot/#/builders?tags=libc

In particular, the 32b arm build bot can take a couple hours to produce relevant test results. Let me know some idea of when you'd like us to merge this.

@overmighty
Copy link
Member Author

Tomorrow early in the morning in your timezone would work.

@nickdesaulniers nickdesaulniers merged commit cd17082 into llvm:main Mar 27, 2024
@overmighty
Copy link
Member Author

@nickdesaulniers
Copy link
Member

I'm going to revert for now.

nickdesaulniers added a commit that referenced this pull request Mar 27, 2024
…romfp{,x}* (#86692)"

This reverts commit cd17082 because the newly
added tests fail on 32b ARM.

Link: #86692
Link: https://lab.llvm.org/buildbot/#/builders/229/builds/24458
@overmighty
Copy link
Member Author

overmighty commented Mar 27, 2024

I think the test failure on 32-bit Arm is caused by this line:

if (width <= FPBits<T>::EXP_BIAS && rounded_value > T(1U << width) - 1U)

All 3 shifts in that function are wrong no matter the target arch, really. The test just unluckily doesn't catch this mistake on x86-64, AArch64 and RV64, because they all only use the lower 5 bits of the shift amount operand when shifting a 32-bit int, so they shift by 0 instead of 32, so the result is still 1 and not 0. ARMv7's "LSL (register)" instruction uses the lower 8 bits of the shift amount operand, so it gets caught there.

I guess I should change the code to use FPBits::set_biased_exponent.

Maybe I should also make use of the LLVM_USE_SANITIZER CMake variable.

overmighty added a commit to overmighty/llvm-project that referenced this pull request Mar 27, 2024
overmighty added a commit to overmighty/llvm-project that referenced this pull request Mar 28, 2024
overmighty added a commit to overmighty/llvm-project that referenced this pull request Apr 12, 2024
…fromfp{,x}* (llvm#86692)"

This reverts commit 8a07167.

The test failure on 32-bit Arm should have been fixed by llvm#86892.
lntue pushed a commit that referenced this pull request Apr 12, 2024
…fromfp{,x}* (#86692)" (#88567)

This reverts commit 8a07167.

The test failure on 32-bit Arm should have been fixed by #86892.

cc @nickdesaulniers @lntue
bazuzi pushed a commit to bazuzi/llvm-project that referenced this pull request Apr 15, 2024
…fromfp{,x}* (llvm#86692)" (llvm#88567)

This reverts commit 8a07167.

The test failure on 32-bit Arm should have been fixed by llvm#86892.

cc @nickdesaulniers @lntue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants