Skip to content

Add f16 and f128 const eval for casting operations #126718

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

Closed
wants to merge 2 commits into from

Conversation

tgross35
Copy link
Contributor

@tgross35 tgross35 commented Jun 20, 2024

This is a continuation of #126429 that should add missing operations.

@rustbot
Copy link
Collaborator

rustbot commented Jun 20, 2024

r? @lcnr

rustbot has assigned @lcnr.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 20, 2024
@tgross35
Copy link
Contributor Author

Still a WIP with the tests

@rustbot author
r? @RalfJung

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 20, 2024
@rustbot rustbot assigned RalfJung and unassigned lcnr Jun 20, 2024
@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-tools failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
## Running ui tests in tests/pass for x86_64-unknown-linux-gnu
   Compiler: "MIRI_ENV_VAR_TEST"="0" "MIRI_TEMP"="/tmp/miri-uitest-Esh5E1" "RUST_BACKTRACE"="1" /checkout/obj/build/x86_64-unknown-linux-gnu/stage1/bin/miri "--error-format=json" "--sysroot=/checkout/obj/build/x86_64-unknown-linux-gnu/miri-sysroot" "-Dwarnings" "-Dunused" "-Ainternal_features" "-Zui-testing" "--target" "x86_64-unknown-linux-gnu" "--out-dir" OUT_DIR

FAILED TEST: tests/pass/float.rs
command: MIRI_ENV_VAR_TEST="0" MIRI_TEMP="/tmp/miri-uitest-Esh5E1" RUST_BACKTRACE="1" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1/bin/miri" "--error-format=json" "--sysroot=/checkout/obj/build/x86_64-unknown-linux-gnu/miri-sysroot" "-Dwarnings" "-Dunused" "-Ainternal_features" "-Zui-testing" "--target" "x86_64-unknown-linux-gnu" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/ui/tests/pass" "tests/pass/float.rs" "--edition" "2021"
error: pass test got exit status: 101, but expected 0

error: actual output differed from expected
Execute `./miri test --bless` to update `tests/pass/float.stderr` to the actual output
Execute `./miri test --bless` to update `tests/pass/float.stderr` to the actual output
--- tests/pass/float.stderr
+++ <stderr output>
+thread 'main' panicked at $DIR/float.rs:LL:CC:
+assertion `left == right` failed
+  left: $HEX
+ right: $HEX
+note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
+note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect

full stderr:
thread 'main' panicked at tests/pass/float.rs:495:5:
assertion `left == right` failed
assertion `left == right` failed
  left: 0x7419
 right: 0x7c00
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
full stdout:


FAILURES:
---
Error: 
   0: ui tests in tests/pass for x86_64-unknown-linux-gnu failed
   1: tests failed

Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.
error: test failed, to rerun pass `--test ui`
Caused by:
  process didn't exit successfully: `/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/x86_64-unknown-linux-gnu/release/deps/ui-ff8e5f7317669711 --quiet` (exit status: 1)
Build completed unsuccessfully in 0:03:28
  local time: Thu Jun 20 00:33:42 UTC 2024


// f16 -> u32
assert_eq::<u32>(f16::MAX as u32, 65504);
assert_eq::<u32>(f16::MIN as u32, 0);
Copy link
Member

Choose a reason for hiding this comment

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

Does this match rustc tests, or is rustc not ready yet to run all of these?
I can't really check whether your values make sense; so far I always did this by just running the test with rustc and then making sure Miri behavior matches rustc behavior.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

rustc should be able to run the f16/f128 on at least Linux x86 and aarch64, but many other platforms are missing the f16/f128 symbols until compiler builtins gets updated. Not sure if you meant fully testing in CI or just locally.

However, I still don't have the constants needed to fully test casting on the new types. So I moved only the test refactoring to its own PR (#126727), and am just going to close this one until #126608 can land.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also there are some ABI issues on x86 without SSE2, which might explain the failure at https://github.com/rust-lang/rust/actions/runs/9589520480/job/26443432727?pr=126718#step:25:3379 (haven't looked too much into it)

@tgross35 tgross35 closed this Jun 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants