Block SIMD in transmute_immediate; delete OperandValueKind#143410
Merged
bors merged 3 commits intorust-lang:masterfrom Jul 5, 2025
Merged
Block SIMD in transmute_immediate; delete OperandValueKind#143410bors merged 3 commits intorust-lang:masterfrom
OperandValueKind#143410bors merged 3 commits intorust-lang:masterfrom
Conversation
Collaborator
|
r? @SparrowLii rustbot has assigned @SparrowLii. Use |
Collaborator
|
Some changes occurred in compiler/rustc_codegen_ssa |
scottmcm
commented
Jul 4, 2025
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); |
Member
Author
There was a problem hiding this comment.
These just disappear entirely because transmute_immediate no longer needs them as arguments 🎉
RalfJung
reviewed
Jul 4, 2025
RalfJung
reviewed
Jul 4, 2025
RalfJung
reviewed
Jul 4, 2025
RalfJung
reviewed
Jul 4, 2025
RalfJung
reviewed
Jul 4, 2025
RalfJung
reviewed
Jul 4, 2025
RalfJung
reviewed
Jul 4, 2025
This comment has been minimized.
This comment has been minimized.
Member
|
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 :) |
337cb31 to
4e61527
Compare
Member
|
The test changes seem to be fine. @bors r+ |
Collaborator
Member
|
@bors r=RalfJung,workingjubilee |
Collaborator
|
💡 This pull request was already approved, no need to approve it again.
|
Collaborator
bors
added a commit
that referenced
this pull request
Jul 5, 2025
Rollup of 11 pull requests Successful merges: - #142440 (`tests/ui`: A New Order [14/N]) - #143040 (Add `const Rem`) - #143086 (Update poison.rs to fix the typo (sys->sync)) - #143202 (`tests/ui`: A New Order [18/N]) - #143296 (`tests/ui`: A New Order [21/N]) - #143297 (`tests/ui`: A New Order [22/N]) - #143299 (`tests/ui`: A New Order [24/N]) - #143300 (`tests/ui`: A New Order [25/N]) - #143397 (test passing a `VaList` from rust to C) - #143410 (Block SIMD in transmute_immediate; delete `OperandValueKind`) - #143452 (Fix CLI completion check in `tidy`) r? `@ghost` `@rustbot` modify labels: rollup
rust-timer
added a commit
that referenced
this pull request
Jul 5, 2025
Rollup merge of #143410 - scottmcm:redo-transmute-again, r=RalfJung,workingjubilee Block SIMD in transmute_immediate; delete `OperandValueKind` 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 `Scalar`s involved -- the backend types can be gotten from those `Scalar`s, 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
bors
added a commit
that referenced
this pull request
Jul 5, 2025
Let `rvalue_creates_operand` return true for *all* `Rvalue::Aggregate`s Draft for now because it's built on Ralf's #143291 Inspired by #138759 (comment) where I noticed that we were nearly at this point, plus the comments I was writing in #143410 that reminded me a type-dependent `true` is fine. This PR splits the `OperandRef::builder` logic out to a separate type, with the updates needed to handle SIMD as well. In doing so, that makes the existing `Aggregate` path in `codegen_rvalue_operand` capable of handing SIMD values just fine. As a result, we no longer need to do layout calculations for aggregate result types when running the analysis to determine which things can be SSA in codegen.
bors
added a commit
that referenced
this pull request
Jul 9, 2025
Let `rvalue_creates_operand` return true for *all* `Rvalue::Aggregate`s ~~Draft for now because it's built on Ralf's #143291~~ Inspired by #138759 (comment) where I noticed that we were nearly at this point, plus the comments I was writing in #143410 that reminded me a type-dependent `true` is fine. This PR splits the `OperandRef::builder` logic out to a separate type, with the updates needed to handle SIMD as well. In doing so, that makes the existing `Aggregate` path in `codegen_rvalue_operand` capable of handing SIMD values just fine. As a result, we no longer need to do layout calculations for aggregate result types when running the analysis to determine which things can be SSA in codegen.
github-actions bot
pushed a commit
to devnexen/miri
that referenced
this pull request
Jul 10, 2025
Let `rvalue_creates_operand` return true for *all* `Rvalue::Aggregate`s ~~Draft for now because it's built on Ralf's rust-lang/rust#143291~~ Inspired by rust-lang/rust#138759 (comment) where I noticed that we were nearly at this point, plus the comments I was writing in rust-lang/rust#143410 that reminded me a type-dependent `true` is fine. This PR splits the `OperandRef::builder` logic out to a separate type, with the updates needed to handle SIMD as well. In doing so, that makes the existing `Aggregate` path in `codegen_rvalue_operand` capable of handing SIMD values just fine. As a result, we no longer need to do layout calculations for aggregate result types when running the analysis to determine which things can be SSA in codegen.
scottmcm
added a commit
to scottmcm/rust
that referenced
this pull request
Jul 10, 2025
Ralf suggested in <rust-lang#143410 (comment)> that UB transmutes shouldn't be trapping, which happened for the one path that PR was changing, but there's another path as well, so this PR changes that other path to match.
tgross35
added a commit
to tgross35/rust
that referenced
this pull request
Jul 10, 2025
…fleLapkin Make UB transmutes really UB in LLVM Ralf suggested in <rust-lang#143410 (comment)> that UB transmutes shouldn't be trapping, which happened for the one path *that* PR was changing, but there's another path as well, so *this* PR changes that other path to match. r? codegen
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this pull request
Jul 11, 2025
…fleLapkin Make UB transmutes really UB in LLVM Ralf suggested in <rust-lang#143410 (comment)> that UB transmutes shouldn't be trapping, which happened for the one path *that* PR was changing, but there's another path as well, so *this* PR changes that other path to match. r? codegen
rust-timer
added a commit
that referenced
this pull request
Jul 12, 2025
Rollup merge of #143718 - scottmcm:ub-transmute-is-ub, r=WaffleLapkin Make UB transmutes really UB in LLVM Ralf suggested in <#143410 (comment)> that UB transmutes shouldn't be trapping, which happened for the one path *that* PR was changing, but there's another path as well, so *this* PR changes that other path to match. r? codegen
LorrensP-2158466
pushed a commit
to LorrensP-2158466/rust
that referenced
this pull request
Jul 13, 2025
Ralf suggested in <rust-lang#143410 (comment)> that UB transmutes shouldn't be trapping, which happened for the one path that PR was changing, but there's another path as well, so this PR changes that other path to match.
lnicola
pushed a commit
to lnicola/rust-analyzer
that referenced
this pull request
Jul 15, 2025
Let `rvalue_creates_operand` return true for *all* `Rvalue::Aggregate`s ~~Draft for now because it's built on Ralf's rust-lang/rust#143291~~ Inspired by rust-lang/rust#138759 (comment) where I noticed that we were nearly at this point, plus the comments I was writing in rust-lang/rust#143410 that reminded me a type-dependent `true` is fine. This PR splits the `OperandRef::builder` logic out to a separate type, with the updates needed to handle SIMD as well. In doing so, that makes the existing `Aggregate` path in `codegen_rvalue_operand` capable of handing SIMD values just fine. As a result, we no longer need to do layout calculations for aggregate result types when running the analysis to determine which things can be SSA in codegen.
lnicola
pushed a commit
to lnicola/rust-analyzer
that referenced
this pull request
Jul 15, 2025
Make UB transmutes really UB in LLVM Ralf suggested in <rust-lang/rust#143410 (comment)> that UB transmutes shouldn't be trapping, which happened for the one path *that* PR was changing, but there's another path as well, so *this* PR changes that other path to match. r? codegen
Kobzol
pushed a commit
to Kobzol/rustc_codegen_gcc
that referenced
this pull request
Dec 21, 2025
Let `rvalue_creates_operand` return true for *all* `Rvalue::Aggregate`s ~~Draft for now because it's built on Ralf's rust-lang/rust#143291~~ Inspired by rust-lang/rust#138759 (comment) where I noticed that we were nearly at this point, plus the comments I was writing in rust-lang/rust#143410 that reminded me a type-dependent `true` is fine. This PR splits the `OperandRef::builder` logic out to a separate type, with the updates needed to handle SIMD as well. In doing so, that makes the existing `Aggregate` path in `codegen_rvalue_operand` capable of handing SIMD values just fine. As a result, we no longer need to do layout calculations for aggregate result types when running the analysis to determine which things can be SSA in codegen.
Kobzol
pushed a commit
to Kobzol/rustc_codegen_gcc
that referenced
this pull request
Dec 21, 2025
Make UB transmutes really UB in LLVM Ralf suggested in <rust-lang/rust#143410 (comment)> that UB transmutes shouldn't be trapping, which happened for the one path *that* PR was changing, but there's another path as well, so *this* PR changes that other path to match. r? codegen
Kobzol
pushed a commit
to Kobzol/rustc_codegen_cranelift
that referenced
this pull request
Dec 29, 2025
Let `rvalue_creates_operand` return true for *all* `Rvalue::Aggregate`s ~~Draft for now because it's built on Ralf's rust-lang/rust#143291~~ Inspired by rust-lang/rust#138759 (comment) where I noticed that we were nearly at this point, plus the comments I was writing in rust-lang/rust#143410 that reminded me a type-dependent `true` is fine. This PR splits the `OperandRef::builder` logic out to a separate type, with the updates needed to handle SIMD as well. In doing so, that makes the existing `Aggregate` path in `codegen_rvalue_operand` capable of handing SIMD values just fine. As a result, we no longer need to do layout calculations for aggregate result types when running the analysis to determine which things can be SSA in codegen.
Kobzol
pushed a commit
to Kobzol/portable-simd
that referenced
this pull request
Feb 3, 2026
Let `rvalue_creates_operand` return true for *all* `Rvalue::Aggregate`s ~~Draft for now because it's built on Ralf's rust-lang/rust#143291~~ Inspired by rust-lang/rust#138759 (comment) where I noticed that we were nearly at this point, plus the comments I was writing in rust-lang/rust#143410 that reminded me a type-dependent `true` is fine. This PR splits the `OperandRef::builder` logic out to a separate type, with the updates needed to handle SIMD as well. In doing so, that makes the existing `Aggregate` path in `codegen_rvalue_operand` capable of handing SIMD values just fine. As a result, we no longer need to do layout calculations for aggregate result types when running the analysis to determine which things can be SSA in codegen.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_immediateit can be simplified to just take theScalars involved -- the backend types can be gotten from thoseScalars, 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_operandto 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
OperandValueKindtype that I added back then which @RalfJung rightly considers pretty sketchy.cc @folkertdev @workingjubilee from the zulip conversation too