1228 Commits

Author SHA1 Message Date
github-actions[bot]
45c4a1d1b5 chore: release v0.1.149 2025-02-25 14:02:15 -05:00
Trevor Gross
55bbda8ff8 Make a subset of libm symbols weakly available on all platforms
018616e78b ("Always have math functions but with `weak` linking
attribute if we can") made all math symbols available on platforms that
support weak linkage. This caused some unexpected regressions, however,
because our less accurate and sometimes slow routines were being
selected over the system `libm`, which also tends to be weak [1]. Thus,
0fab77e8d7 ("Don't include `math` for `unix` and `wasi` targets") was
applied to undo these changes on many platforms.

Now that some improvements have been made to `libm`, add back a subset
of these functions:

* cbrt
* ceil
* copysign
* fabs
* fdim
* floor
* fma
* fmax
* fmaximum
* fmin
* fminimum
* fmod
* rint
* round
* roundeven
* sqrt
* trunc

This list includes only functions that produce exact results (verified
with exhaustive / extensive tests, and also required by IEEE in most
cases), and for which benchmarks indicate performance similar to or
better than Musl's soft float math routines [^1]. All except `cbrt` also
have `f16` and `f128` implementations. Once more routines meet these
criteria, we can move them from platform-specific availability to always
available.

Once this change makes it to rust-lang/rust, we will also be able to
move the relevant functions from `std` to `core`.

[^1]: We still rely on the backend to provide optimized assmebly
      routines when available.

[1]: https://github.com/rust-lang/rust/issues/128386
2025-02-25 13:54:56 -05:00
github-actions[bot]
95a5ad5225 chore: release v0.1.148 2025-02-24 02:43:13 -05:00
Trevor Gross
7055198acf Update the libm submodule
This requires privately reexporting `libm`'s `support` module at crate
root, where it is expected for macros. Once `libm` is made always
available, the reexport can be simplified.

This delta adds a lot of routines to `f16` and `f128`:

* ceil
* floor
* fma (f128 only)
* fmax
* fmin
* fmod
* ldexp
* rint
* round
* scalbn
* sqrt

Additionally, the following new API was added for all four float types:

* fmaximum
* fmaximum_num
* fminimum
* fminimum_num
* roundeven

There are also some significant performance improvements for `sqrt` and
`sqrtf`, as well as precision improvements for `cbrt` (both `f32` and
`f64` versions of this function are now always correctly rounded).
2025-02-24 02:33:36 -05:00
Martin Nordholts
49224fb9ed Enable f16 for MIPS
It seems as if `f16` works on MIPS now according to my
testing on Rust master with LLVM 20, and I was asked to
create PRs with my changes.

I only tested on the flavour of `mipsel-unknown-linux-gnu`
hardware that happens to be available to me, so I can't say
anything about other MIPS hardware, but from a casual
skimming of the LLVM code ([1], [2]) it seems like `f16`
should work on all MIPS hardware. So enable it for all MIPS
hardware.

[1]: https://github.com/rust-lang/llvm-project/blob/rustc/20.1-2025-02-13/llvm/lib/Target/Mips/MipsISelLowering.h#L370
[2]: https://github.com/rust-lang/llvm-project/blob/rustc/20.1-2025-02-13/llvm/lib/CodeGen/TargetLoweringBase.cpp#L1367-L1388
2025-02-23 22:40:57 -05:00
Trevor Gross
f42c9632a6 Eliminate the use of public_test_dep! for a third time
Replace `public_test_dep!` by placing optionally public items into new
modules, then controlling what is exported with the `public-test-deps`
feature.

This is nicer for automatic formatting and diagnostics.

This is a reland of 2e2a9255 ("Eliminate the use of
`public_test_dep!`"), which was reverted in 47e50fd2 ('Revert "Eliminate
the use of..."') due to a bug exposed at [1], reapplied in d4abaf4efa
because the issue should have been fixed in [2], then reverted again in
f6eef07f53 because [2] did not actually fix the issue.

[3] has landed in rust-lang/rust since then, which should resolve the
last problem remaining after [2]. So, apply this change for what is
hopefully the final time.

[1]: https://github.com/rust-lang/rust/pull/128691
[2]: https://github.com/rust-lang/rust/pull/135278
[3]: https://github.com/rust-lang/rust/pull/135501
2025-02-23 22:34:40 -05:00
Trevor Gross
54e7ff15c0 Revert "ci: Pin the nightly toolchain for i686-pc-windows-gnu"
Since [1], the issue should be resolved so the workaround can be
dropped.

This reverts commit 88e83b96ad09f3cf9e2d1b4543a7d43f9c5a77c0.

[1]: https://github.com/rust-lang/compiler-builtins/pull/759
2025-02-23 03:40:11 -05:00
github-actions[bot]
f851256581 chore: release v0.1.147 2025-02-19 19:16:19 -05:00
Ralf Jung
2b6de7a68f remove win64_128bit_abi_hack 2025-02-19 15:44:43 -05:00
Trevor Gross
bade6290c8 ci: Pin the nightly toolchain for aarch64-unknown-linux-gnu
Pin aarch64-unknown-linux-gnu to nightly-2025-02-07 until [1] is
resolved.

[1]: https://github.com/llvm/llvm-project/issues/127804
2025-02-19 15:38:45 -05:00
Trevor Gross
4517c7ea90 ci: Pin the nightly toolchain for i686-pc-windows-gnu
Pin i686-pc-windows-gnu to nightly-2025-02-07 until [1] is resolved.

[1]: https://github.com/rust-lang/rust/issues/136795
2025-02-19 15:38:45 -05:00
Trevor Gross
37da10edde ci: Update actions/cache to v4
Github has deprecated v2 so this needs to be bumped.
2025-02-19 15:38:45 -05:00
github-actions[bot]
84cb50e5b5 chore: release v0.1.146 2025-02-06 17:46:20 -06:00
Pavel Grigorenko
7f3bd59cdf Expose erf{,c}{,f} from libm 2025-02-06 14:54:58 -06:00
github-actions[bot]
dbd3032d42
chore: release v0.1.145 2025-02-04 10:46:49 +00:00
Trevor Gross
57572a583d Revert "Eliminate the use of public_test_dep!"
[1] has not gone forward, so this needs to be reverted again in order to
unblock a compiler-builtins upgrade that is necessary for the LLVM 20
upgrade.

This reverts commit a2494f14e99ae90c964f12bf0c059d63ccc07c2a.

[1]: https://github.com/rust-lang/rust/pull/135501
2025-02-04 04:46:24 -06:00
Pavel Grigorenko
5a5a5a39ad Indentation fix to please clippy 2025-01-31 17:50:46 -06:00
Nikita Popov
ececfaba78 Don't build out of line atomics support code for uefi
https://github.com/llvm/llvm-project/pull/116706 added Windows
support to cpu_model. Compiling for UEFI also goes through that
code path, because we treat it as a windows target. However,
including windows.h is not actually going to work (and the used
API would not be available in an UEFI environment).

Disable building of cpu_model on UEFI to fix this.
2025-01-28 14:06:54 -06:00
Trevor Gross
4e1b885595 Add a version to some FIXMEs that will be resolved in LLVM 20 2025-01-27 20:27:53 -06:00
Trevor Gross
64e0a0a68d Remove use of the start feature
`#![feature(start)]` was removed in [1], but we make use of it in the
intrinsics example. Replace use of this feature with `#[no_mangle]`
applied to `#[main]`.

We don't actually run this example so it is not a problem if this is not
entirely accurate. Currently the example does not run to completion,
instead invoking `rust_begin_unwind`.

[1]: https://github.com/rust-lang/rust/pull/134299
2025-01-27 20:09:47 -06:00
github-actions[bot]
49595ea04e
chore: release v0.1.144 2025-01-15 21:19:09 +00:00
Trevor Gross
095ecabcad Eliminate the use of public_test_dep!
Replace `public_test_dep!` by placing optionally public items into new
modules, then controlling what is exported with the `public-test-deps`
feature.

This is nicer for automatic formatting and diagnostics.

This is a reland of 2e2a9255 ("Eliminate the use of
`public_test_dep!`"), which was reverted in 47e50fd2 ('Revert "Eliminate
the use of..."') due to a bug exposed at [1]. This was fixed in [2], so
the cleanup should be able to be applied again.

[1]: https://github.com/rust-lang/rust/pull/128691
[2]: https://github.com/rust-lang/rust/pull/135278
2025-01-15 16:18:41 -05:00
github-actions[bot]
05d429523d
chore: release v0.1.143 2025-01-15 03:53:29 +00:00
Trevor Gross
7a87cdbae5 Use a C-safe return type for __rust_[ui]128_* overflowing intrinsics
Most of our Rust-specific overflowing intrinsics currently return
`(i128, bool)`, which is not guaranteed to have a stable ABI. Switch to
returning the overflow via a mutable parameter and only directly
returning the integer result.

`__rust_i128_mulo` now matches the function signature of `__muloti4`,
but they do not share the same ABI on Windows so we cannot easily
deduplicate them.
2025-01-14 22:53:04 -05:00
github-actions[bot]
d0a79fd542
chore: release v0.1.142 2025-01-07 23:21:35 +00:00
Trevor Gross
83a61e67fd Account for optimization levels other than numbers
The build script currently panics with `opt-level=z` or `opt-level=s`.
Account for this here.

This is the `compiler-builtins` version of [1].

Fixes: https://github.com/rust-lang/compiler-builtins/issues/742

[1]: https://github.com/rust-lang/libm/pull/417
2025-01-07 18:13:04 -05:00
Trevor Gross
77f34f3a4c Update the libm submodule
This includes [1], which fixes a bug parsing non-numeric optimization
levels.

[1]: https://github.com/rust-lang/libm/pull/417
2025-01-07 18:11:40 -05:00
github-actions[bot]
1b0adb233c
chore: release v0.1.141 2025-01-07 01:57:53 +00:00
Trevor Gross
e6ea2802d1 Update the libm submodule 2025-01-06 20:57:24 -05:00
Trevor Gross
f4f942c3e9 Update the libm submodule 2025-01-06 19:17:41 -05:00
Trevor Gross
5d60d2a905 Fix new clippy::precedence errors
`clippy::precedence` now applies to bitwise `&` and `|`. Update with all
of its suggestions, including a separate elided lifetime suggestion.
2025-01-03 03:09:07 +00:00
Trevor Gross
7065cd0420 Rename EXP_MAX to EXP_SAT
"Maximum" is technically correct here with regards to what the
bitpattern can represent, but it is not the numeric maximum value of the
exponent which has a relationship with the bias. So, replace the maximum
terminology with "saturated" to indicate it only means the full
bitpattern.

This change is more relevant to `libm` than `compiler-builtins`.
2025-01-03 02:56:34 +00:00
Trevor Gross
b47d3cc2f8 Shorten prefixes for float constants
Change `SIGNIFICAND_*` to `SIG_*` and `EXPONENT_*` to `EXP_*`. This
makes things more consistent with `libm`, and terseness is convenient
here since there isn't anything to confuse.
2025-01-03 02:54:56 +00:00
github-actions[bot]
a078f5a0c5 chore: release v0.1.140 2024-12-26 00:16:33 -05:00
Sebastian Neubauer
e8eb76a45a
Disable f128 for amdgpu (#737)
`compiler_builtins` fails to compile to amdgpu if f128 is enabled.
The reason seems to be that compiler_builtins uses libcalls in the
implementation. I’m not really familiar with what libcalls are, but the
LLVM amdgpu backend explicitly does not support them.

Error message:
```
LLVM ERROR: unsupported libcall legalization
```
2024-12-26 00:01:14 -05:00
Trevor Gross
a4d9b4a6a2 Fix a bug in abs_diff
These implementations of `abs_diff` were added in c2ff1b3119
("Completely overhaul fuzz testing"), but the signed implementation is
wrong when |x| + |y| exceeds the integer's limits (e.g.
`(-128).abs_diff(1)` should be 128 but currently these return 127.

Resolve this by just using `std`'s implementation since that is stable
now. This isn't used anywhere critical, we probably just weren't hitting
the edge case.
2024-12-22 22:08:31 +00:00
Trevor Gross
04ccb683d9 Disable f16 on platforms that have recursion problems
CI in [1] seems to indicate that there are cases where the `f16`
infinite recursion bug ([2], [3]) can make its way into what gets called
during tests, even though this doesn't seem to be the usual case. In
order to make sure that we avoid these completely, just unset
`f16_enabled` on any platforms that have the recursion problem.

This also refactors the `match` statement to be more in line with
`library/std/build.rs`.

[1]: https://github.com/rust-lang/compiler-builtins/pull/729
[2]: https://github.com/llvm/llvm-project/issues/97981
[3]: https://github.com/rust-lang/compiler-builtins/issues/651
2024-11-05 02:57:34 -06:00
github-actions[bot]
c33f521bb5
chore: release v0.1.139 2024-11-03 23:08:41 +00:00
beetrees
10bdf3b6c1
Remove incorrect sparcv9 match pattern from configure_f16_f128 2024-11-03 22:54:01 +00:00
github-actions[bot]
4c7450d10c
chore: release v0.1.138 2024-11-01 11:00:27 +00:00
Trevor Gross
28fb4bc868 Enable the changelog for release-plz
This crate isn't meant for direct use, but having an easy way to see
what changed between versions would still be helpful when this crate is
updated in rust-lang/rust.
2024-11-01 05:59:57 -05:00
WANG Rui
ec673535f7 ci: add support for loongarch64-unknown-linux-gnu 2024-11-01 05:48:47 -05:00
hev
ca996df5c1
Use f16_enabled/f128_enabled in examples/intrinsics.rs (#724)
Enable conditional compilation for intrinsics with `f16_enabled` and `f128_enabled`
2024-11-01 10:34:51 +00:00
hev
53b3e71bbc
Disable f16 for LoongArch64 (#722)
Disable `f161` for LoongArch64 due to incorrect code generation on LLVM 19,
which causes failures in `testcrate/tests/conv.rs`. This workaround will
remain in place until llvm/llvm-project#109093 is merged or we upgrade to
LLVM 20.
2024-11-01 10:00:00 +00:00
github-actions[bot]
94e6ed373a chore: release v0.1.137 2024-10-31 19:13:38 -05:00
Trevor Gross
9818afad7c Remove the unneeded isqrt feature gate
[1] has been stabilized so we no longer need to enable it.

[1]: https://github.com/rust-lang/rust/issues/116226
2024-10-30 12:27:59 -05:00
Trevor Gross
fbd6907358 Add integer to f128 conversions 2024-10-30 12:25:24 -05:00
Trevor Gross
51dd4da053 Refactor integer to float conversion
Extract some common routines to separate functions in order to
deduplicate code and remove some of the magic.
2024-10-30 12:25:22 -05:00
Trevor Gross
1dc50415cd Add an apfloat fallback for int to float tests 2024-10-30 12:22:57 -05:00
github-actions[bot]
f9914e98b3
chore: release v0.1.136 2024-10-26 23:29:14 +00:00