Skip to content

Block SIMD in transmute_immediate; delete OperandValueKind #143410

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

scottmcm
Copy link
Member

@scottmcm scottmcm commented Jul 4, 2025

Vectors have been causing me problems for years in this code, for example #110021 (comment) and #143194

See conversation in https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Is.20transmuting.20a.20.60T.60.20to.20.60Tx1.60.20.28one-element.20SIMD.20vector.29.20UB.3F/near/526262799.

By blocking SIMD in transmute_immediate it can be simplified to just take the Scalars involved -- the backend types can be gotten from those Scalars, rather than needing to be passed. And there's an assert added to ICE it if it does get hit.

Accordingly, this changes rvalue_creates_operand to not send SIMD transmutes through the operand path, but to always go through memory instead, like they did back before #108442.

And thanks to those changes, I could also remove the OperandValueKind type that I added back then which @RalfJung rightly considers pretty sketchy.

cc @folkertdev @workingjubilee from the zulip conversation too

@rustbot
Copy link
Collaborator

rustbot commented Jul 4, 2025

r? @SparrowLii

rustbot has assigned @SparrowLii.
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 Jul 4, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jul 4, 2025

Some changes occurred in compiler/rustc_codegen_ssa

cc @WaffleLapkin

Comment on lines -300 to -303
let in_a_ibty = bx.scalar_pair_element_backend_type(operand.layout, 0, false);
let in_b_ibty = bx.scalar_pair_element_backend_type(operand.layout, 1, false);
let out_a_ibty = bx.scalar_pair_element_backend_type(cast, 0, false);
let out_b_ibty = bx.scalar_pair_element_backend_type(cast, 1, false);
Copy link
Member Author

Choose a reason for hiding this comment

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

These just disappear entirely because transmute_immediate no longer needs them as arguments 🎉

@rust-log-analyzer

This comment has been minimized.

@RalfJung
Copy link
Member

RalfJung commented Jul 4, 2025

At this point I am happy with the codegen changes, but I have a hard time interpreting the test changes. Wouldn't mind someone else to take a look at those :)

@scottmcm scottmcm force-pushed the redo-transmute-again branch from 337cb31 to 4e61527 Compare July 4, 2025 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants