Repository navigation
fix(mir-lower): give an aggregate niche payload's leaves typed slots - #1591
Merged
Merged
Conversation
An enum payload that is a struct or tuple with a pointer niche carrier and
non-pointer leaves (`Option<(f32, f32, &mut T)>`, `Option<{&mut T, u64, u64}>`)
gave only the pointer leaf a typed slot. The other leaves fell into
`[N x i8]` filler bytes, so construct spilled the payload through a slot and
the payload read loaded it back at another width. SROA cannot rebuild
mixed-type slices, and the slot reached PTX as a local depot.
Every leaf of such a payload now claims a typed slot at its rustc offset,
reusing the carrier's slot where the types match, with construct and payload
reads using insertvalue/extractvalue; size, alignment, field offsets and the
niche encoding are unchanged, and a payload the rule cannot prove keeps the
old lowering.
Measured with one device-only probe source against each tree's backend:
parent e027ac3 emits a 16 B `.local` depot in the `smooth_triplets` entry
plus 16 B in the outlined `Cells::next_cell`; this commit emits none.
`lease_borrow` and `lease_raw` emit none on either commit.
Across the 241 examples under rustc-codegen-cuda/examples, only
enum_niche_payload and set_discriminant_niche change PTX, and both lose
their 16 B depot; vectorization and repr_u32_enum_stride are unchanged per
entry.
The NVIDIA#1332 slot-map test now expects the 16 bytes under the carrier as one
i128 slot instead of [2 x i64] filler; alignment stays 16.
Adds the enum_niche_payload example and the leaf-slot unit tests.
Signed-off-by: midagedev <[email protected]>
Collaborator
|
/ok to test 3c953b7 |
@nihalpasham, there was an error processing your request: See the following link for more information: https://docs.gha-runners.nvidia.com/cpr/e/2/ |
nihalpasham
previously approved these changes
Nov 3, 2026
Collaborator
|
/ok to test 3c953b7 |
Collaborator
|
Thanks, decomposing pointer-niche struct/tuple payloads into per-leaf typed slots when every leaf is aligned and non-overlapping eliminates the
Verified |
Signed-off-by: nihalpasham <[email protected]>
nihalpasham
force-pushed
the
fix/niche-payload-leaf-slots
branch
from
November 3, 2026 06:42
3c953b7 to
1103a60
Compare
nihalpasham
approved these changes
Nov 3, 2026
Collaborator
|
/ok to test 1103a60 |
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.
What This PR Does
Decomposes struct/tuple enum payloads with a pointer niche (
Option<RopePair>,Option<(f32, f32, &mut f32)>,Option<(usize, &T)>) into per-leaf typed slots inmir-lower(build_enum_slot_map), keeping construction and payload extraction in SSA registers instead of spilling through a.localstack depot.Why Pointer-Niche Struct/Tuple Payloads Spilled to
.localPreviously, when a struct or tuple payload inside an
Optionhad its niche on a pointer field,build_enum_slot_mapgave only the pointer a typed slot in the enum's LLVM struct and represented all other fields as[N x i8]ori64filler bytes. Reading or writing the payload then went through anallocastack slot with byte-slice stores and a wide struct load, which LLVM's SROA pass could not promote back to registers.i1(bool).Verification
RTX 5090,sm_120a):cargo oxide run enum_niche_payloadand--verify-ptxpass with0.localbytes across all entries (compute-sanitizer --tool memcheck:0 errors);set_discriminant_nichealso drops from16 B.localto0 B.cargo test -p mir-lower --all-targets(517/517 PASS),just fmt-check,cargo clippy, and repository guards all pass.Closes #1590