-
Notifications
You must be signed in to change notification settings - Fork 213
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
Add missing functions for f16
and f128
#587
Conversation
fc0051a
to
405f0aa
Compare
@Amanieu this will be the corresponding update to builtins once rust-lang/rust#122470 merges. How do I need to gate things here since it will only work with a recent nightly? |
compiler-builtins is effectively an internal implementation detail of rustc, you're not meant to use it directly. So it therefore only supports the latest rustc anyways. However you may have problems with bootstrap since that uses the latest beta which won't have support for the |
README.md
Outdated
@@ -264,7 +269,6 @@ These builtins involve floating-point types ("`f128`", "`f80`" and complex numbe | |||
- ~~ppc/gcc_qmul.c~~ | |||
- ~~ppc/gcc_qsub.c~~ | |||
- ~~ppc/multc3.c~~ | |||
- ~~subtf3.c~~ | |||
- ~~trunctfdf2.c~~ | |||
- ~~trunctfsf2.c~~ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure these aren't needed? I would expect all the tf
builtins to be needed for f128
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are, I just wanted to get arithmetic passing before working on those.
Awesome, thanks for the information. Luckily compiler support did get merged right before the beta branch so I have been able to avoid |
d6c05d0
to
e5e93e8
Compare
What is the best way to test this locally? For everything I have tried, the macros at compiler-builtins/testcrate/tests/lse.rs Lines 94 to 100 in 7240849
./ci/run-docker.sh doesn't find the right linker. Then the tests at https://github.com/tgross35/compiler-builtins/blob/7d347bb9e348e070a87b4123a29c3fdd796d4dee/testcrate/tests/addsub.rs#L112 fail because the symbols to compare against aren't available on my machine (which is aarch64, maybe I just need to gate this?).
Looking forward to being able to get some output from CI but I'm still waiting on nightly to catch up 🙂 |
Normally If you're feeling adventurous, you can try fixing the tests to work on an aarch64 host. Regarding the LSE issues, I think that may be because you are on an Apple system where these symbols don't exist. That test should be gated on |
The linker just wasn't available on ubuntu 18, but I had to add a way to not use host rustc. Opened #591 to add a way to use a different image |
7d347bb
to
a467dd2
Compare
@@ -201,6 +201,10 @@ intrinsics! { | |||
add(a, b) | |||
} | |||
|
|||
pub extern "C" fn __addtf3(a: f128, b: f128) -> f128 { | |||
add(a, b) | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will unconditionally codegen f16 and f128 usage, breaking cg_clif and cg_gcc. Maybe add a cargo feature to disable these new intrinsics?
cb353e2
to
44c414f
Compare
32d6c0f
to
db3fb45
Compare
a19f4ec
to
53203b0
Compare
My widening function is failing at "0xffffffffffffffffffffffffffffffff * 0xffffffffffffffffffffffffffffffff = 0xfffffffffffffffffffffffffffffffe00000000000000000000000000000001 got 0xfffffffffffffffffffffffffffffffd00000000000000000000000000000001", https://github.com/rust-lang/compiler-builtins/actions/runs/8717331100/job/23912367209?pr=587#step:9:370. This seems to be identical to what LLVM's >>> hex(0xffffffffffffffffffffffffffffffff * 0xffffffffffffffffffffffffffffffff)
'0xfffffffffffffffffffffffffffffffe00000000000000000000000000000001' Relevant code if anyone has any ideas compiler-builtins/src/int/big.rs Lines 233 to 284 in 3cc6355
|
5dc5fda
to
e03afc8
Compare
AFAICT the code is dropping a carry with the
Should probably be something like:
|
Thanks @marthadev, I just today realized that we have a nightly |
TIL, it does indeed look nice
The LLVM implementation seems to have the same problem, which honestly surprises me given that the code is 10 years old. I have no clue though how widely that function is being used, but having a logic bug in integer arithmetic seems pretty bad, so I am glad you found it. Edit: Curiously enough, the LLVM 64x64 version even explicitly comments about the carry |
I opened an issue at llvm/llvm-project#90009 for the LLVM side to take a look at, thanks for confirming. |
fcd9612
to
6d70c0f
Compare
Try splitting part of 'Int' into 'MinInt' so we don't need to implement everything on u256/i256 Add addsub test Add mul/div/rem tests Add cmp test Remove 32-bit div implementation formatting updates disable div tests for now Bigint updates Big update Fix widen mul wrapping add disable duplicate symbols in builtins Apply temporary unord fix from @beetrees rust-lang#593 tests add lowerhex display errors by ref tests fix-test Update big tests Fix core calls Disable widen_mul for signed Test adding symbols in build.rs Add a feature to compile intrinsics that are missing on the system for testing update Disable f128 tests on platforms without system support add missing build.rs file pull cas file from master testgs print more div values Add a benchmark Work on fixing bit widths Update benchmark
6d70c0f
to
bbe3aef
Compare
Everything except division has been cleaned up and split off to #606 |
Superceded by a few PRs, many have merged already. |
Fixes #567