Skip to content

test f16::mul_add not double-rounding the result - #161522

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
folkertdev:gcc-fma16-correctly-rounded
Aug 25, 2026
Merged

test f16::mul_add not double-rounding the result#161522
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
folkertdev:gcc-fma16-correctly-rounded

Conversation

@folkertdev

@folkertdev folkertdev commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

test the precision of f16::mul_add. The semantics of mul_add are that there should only be one rounding of the final result back into the storage type, i.e. the intermediate result of the multiplication should not be rounded.

A naive implementation of f16::mul_add as f32::mul_add(a as f32, b as f32, c as f32) as f16 has insufficient precision, see llvm/llvm-project#98389.

Our rustc_codegen_gcc backend still used the f32 approach, this PR changes it to instead (implicitly) use the fallback body from core, which uses f64::mul_add so that the result is correctly rounded.

A naive `f32::mul_add(a as f32, b as f32, c as f32) as f16` has insufficient precision
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 22, 2026
@folkertdev

Copy link
Copy Markdown
Contributor Author

@bors try jobs=test-various,aarch64-apple-,-gnu-nopt-,x86_64-mingw-,aarch64-msvc-*,arm-android

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Aug 22, 2026
test `f16::mul_add` not double-rounding the result


try-job: test-various
try-job: aarch64-apple-*
try-job: *-gnu-nopt-*
try-job: x86_64-mingw-*
try-job: aarch64-msvc-*
try-job: arm-android
@rust-bors

rust-bors Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 9c9bbf8 (9c9bbf845b3afa4787e2d5f8551ef27e610679d6)
Base parent: def3ee9 (def3ee9e4f0fe1429574f402bb624439bbd13fc6)

@folkertdev

Copy link
Copy Markdown
Contributor Author

Apparently our CI can handle this

r? tgross35

@rustbot

rustbot commented Aug 22, 2026

Copy link
Copy Markdown
Collaborator

tgross35 is currently at their maximum review capacity.
They may take a while to respond.

@folkertdev folkertdev added the F-f16_and_f128 `#![feature(f16)]`, `#![feature(f128)]` label Aug 22, 2026
@folkertdev
folkertdev marked this pull request as ready for review August 22, 2026 16:13
@rustbot

rustbot commented Aug 22, 2026

Copy link
Copy Markdown
Collaborator

rustc_codegen_gcc is developed in its own repository. If possible, consider making this change to rust-lang/rustc_codegen_gcc instead.

cc @antoyo, @GuillaumeGomez

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 22, 2026

@tgross35 tgross35 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Contents LGTM but could you say what's going on with GCC in the commit message and/or description? They only mention the test, not the behavior change of switching to the f64 fallback.

r=me after that

View changes since this review

@folkertdev

Copy link
Copy Markdown
Contributor Author

updated the description

@bors r=tgross35 rollup

@rust-bors

rust-bors Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

📌 Commit a5f0125 has been approved by tgross35

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 25, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 25, 2026
…nded, r=tgross35

test `f16::mul_add` not double-rounding the result

test the precision of `f16::mul_add`. The semantics of `mul_add` are that there should only be one rounding of the final result back into the storage type, i.e. the intermediate result of the multiplication should not be rounded.

A naive implementation of `f16::mul_add` as `f32::mul_add(a as f32, b as f32, c as f32) as f16` has insufficient precision, see llvm/llvm-project#98389.

Our `rustc_codegen_gcc` backend still used the `f32` approach, this PR changes it to instead (implicitly) use the fallback body from `core`, which uses `f64::mul_add` so that the result is correctly rounded.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 25, 2026
…nded, r=tgross35

test `f16::mul_add` not double-rounding the result

test the precision of `f16::mul_add`. The semantics of `mul_add` are that there should only be one rounding of the final result back into the storage type, i.e. the intermediate result of the multiplication should not be rounded.

A naive implementation of `f16::mul_add` as `f32::mul_add(a as f32, b as f32, c as f32) as f16` has insufficient precision, see llvm/llvm-project#98389.

Our `rustc_codegen_gcc` backend still used the `f32` approach, this PR changes it to instead (implicitly) use the fallback body from `core`, which uses `f64::mul_add` so that the result is correctly rounded.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 25, 2026
…nded, r=tgross35

test `f16::mul_add` not double-rounding the result

test the precision of `f16::mul_add`. The semantics of `mul_add` are that there should only be one rounding of the final result back into the storage type, i.e. the intermediate result of the multiplication should not be rounded.

A naive implementation of `f16::mul_add` as `f32::mul_add(a as f32, b as f32, c as f32) as f16` has insufficient precision, see llvm/llvm-project#98389.

Our `rustc_codegen_gcc` backend still used the `f32` approach, this PR changes it to instead (implicitly) use the fallback body from `core`, which uses `f64::mul_add` so that the result is correctly rounded.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 25, 2026
…nded, r=tgross35

test `f16::mul_add` not double-rounding the result

test the precision of `f16::mul_add`. The semantics of `mul_add` are that there should only be one rounding of the final result back into the storage type, i.e. the intermediate result of the multiplication should not be rounded.

A naive implementation of `f16::mul_add` as `f32::mul_add(a as f32, b as f32, c as f32) as f16` has insufficient precision, see llvm/llvm-project#98389.

Our `rustc_codegen_gcc` backend still used the `f32` approach, this PR changes it to instead (implicitly) use the fallback body from `core`, which uses `f64::mul_add` so that the result is correctly rounded.
rust-bors Bot pushed a commit that referenced this pull request Aug 25, 2026
…uwer

Rollup of 13 pull requests

Successful merges:

 - #158874 (hir_ty_lowering: fix anon const type recovery)
 - #161443 (add internal DSL for testing binders)
 - #161617 (Add custom allocators to `(try_)map` on `Box`, `Rc`, `Arc`)
 - #161726 (Fix debugger visualizer tuple child ordering w/ PDB debug info)
 - #161729 (miri subtree update)
 - #161745 (make trivial ABI check resilient against new repr)
 - #160871 (Remove `#[rustc_reservation_impl]`)
 - #161180 (Detect missing binding available: add a MaybeIncorrect suggestion)
 - #161522 (test `f16::mul_add` not double-rounding the result)
 - #161631 (Add two comments relating to new-solver performance)
 - #161724 (Add codegen test for static table search loop unrolling)
 - #161740 (do not compress debuginfo for Cygwin)
 - #161750 (vector ABI check: reword so it makes more sense for non-obviously-vector types)
@rust-bors
rust-bors Bot merged commit 80f7443 into rust-lang:main Aug 25, 2026
14 checks passed
@rustbot rustbot added this to the 1.100.0 milestone Aug 25, 2026
rust-bors Bot pushed a commit that referenced this pull request Aug 25, 2026
Rollup merge of #161522 - folkertdev:gcc-fma16-correctly-rounded, r=tgross35

test `f16::mul_add` not double-rounding the result

test the precision of `f16::mul_add`. The semantics of `mul_add` are that there should only be one rounding of the final result back into the storage type, i.e. the intermediate result of the multiplication should not be rounded.

A naive implementation of `f16::mul_add` as `f32::mul_add(a as f32, b as f32, c as f32) as f16` has insufficient precision, see llvm/llvm-project#98389.

Our `rustc_codegen_gcc` backend still used the `f32` approach, this PR changes it to instead (implicitly) use the fallback body from `core`, which uses `f64::mul_add` so that the result is correctly rounded.
pull Bot pushed a commit to LeeeeeeM/miri that referenced this pull request Aug 26, 2026
…uwer

Rollup of 13 pull requests

Successful merges:

 - rust-lang/rust#158874 (hir_ty_lowering: fix anon const type recovery)
 - rust-lang/rust#161443 (add internal DSL for testing binders)
 - rust-lang/rust#161617 (Add custom allocators to `(try_)map` on `Box`, `Rc`, `Arc`)
 - rust-lang/rust#161726 (Fix debugger visualizer tuple child ordering w/ PDB debug info)
 - rust-lang/rust#161729 (miri subtree update)
 - rust-lang/rust#161745 (make trivial ABI check resilient against new repr)
 - rust-lang/rust#160871 (Remove `#[rustc_reservation_impl]`)
 - rust-lang/rust#161180 (Detect missing binding available: add a MaybeIncorrect suggestion)
 - rust-lang/rust#161522 (test `f16::mul_add` not double-rounding the result)
 - rust-lang/rust#161631 (Add two comments relating to new-solver performance)
 - rust-lang/rust#161724 (Add codegen test for static table search loop unrolling)
 - rust-lang/rust#161740 (do not compress debuginfo for Cygwin)
 - rust-lang/rust#161750 (vector ABI check: reword so it makes more sense for non-obviously-vector types)
flip1995 pushed a commit to flip1995/rust-clippy that referenced this pull request Aug 28, 2026
…uwer

Rollup of 13 pull requests

Successful merges:

 - rust-lang/rust#158874 (hir_ty_lowering: fix anon const type recovery)
 - rust-lang/rust#161443 (add internal DSL for testing binders)
 - rust-lang/rust#161617 (Add custom allocators to `(try_)map` on `Box`, `Rc`, `Arc`)
 - rust-lang/rust#161726 (Fix debugger visualizer tuple child ordering w/ PDB debug info)
 - rust-lang/rust#161729 (miri subtree update)
 - rust-lang/rust#161745 (make trivial ABI check resilient against new repr)
 - rust-lang/rust#160871 (Remove `#[rustc_reservation_impl]`)
 - rust-lang/rust#161180 (Detect missing binding available: add a MaybeIncorrect suggestion)
 - rust-lang/rust#161522 (test `f16::mul_add` not double-rounding the result)
 - rust-lang/rust#161631 (Add two comments relating to new-solver performance)
 - rust-lang/rust#161724 (Add codegen test for static table search loop unrolling)
 - rust-lang/rust#161740 (do not compress debuginfo for Cygwin)
 - rust-lang/rust#161750 (vector ABI check: reword so it makes more sense for non-obviously-vector types)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

F-f16_and_f128 `#![feature(f16)]`, `#![feature(f128)]` S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants