-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Pick the largest niche even if the largest niche is wrapped around #144577
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
Conversation
assert::is_transmutable::<OptionLike, u8>(); | ||
assert::is_transmutable::<V0, OptionLike>(); | ||
assert::is_transmutable::<V1, OptionLike>(); | ||
assert::is_transmutable::<V254, OptionLike>(); | ||
assert::is_transmutable::<V255, OptionLike>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jswrenn I'm not sure how to properly fix this test to check what it was checking before. I guess I could create enums with all but a few variants?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So long as you're confident that the revised test will fail if the niche selection process is changed, I'm not too opinionated about the exact approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah oops. Should have done this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will create a PR, but it may take 4 weeks as I'm going on vacation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem; happy to review it when you do so!
// If there are no negative values, we can use the unsigned fit. | ||
if min >= 0 { | ||
// Pick the smallest fit. | ||
if unsigned_fit <= signed_fit { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This affected no tests on its own (but is needed for this PR, as previously it was assumed that min < max), but I think it is strictly better, I'm not expecting signed ops to be slower or anything
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Signed ops can actually optimize better, even, since sub nuw %x, 1
turns into add %x, -1
whereas sub nsw %x, 1
keeps its nowrap flag becoming add nsw %x, -1
.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But yeah, if it's the same integer size either way it probably doesn't matter which is chosen.
This comment has been minimized.
This comment has been minimized.
compiler/rustc_abi/src/layout.rs
Outdated
.map(|(_, val)| { | ||
if discr_type.is_signed() { | ||
// sign extend the raw representation to be an i128 | ||
(val << (128 - bits)) >> (128 - bits) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you have the discr_int.size()
, so you can do https://doc.rust-lang.org/nightly/nightly-rustc/rustc_abi/struct.Size.html#method.sign_extend instead of writing this out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point. it was preexisting, so I'll pack it into a separate commit.
compiler/rustc_abi/src/layout.rs
Outdated
// Since they were sorted, we can now compute the niche sizes and pick the largest. | ||
let discriminants = discriminants.zip(next_discriminants); | ||
let largest_niche = discriminants.max_by_key(|&(start, end)| { | ||
if start <= end { end - start } else { discr_int.signed_max() - (start - end) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I'm kinda surprised to see the start <= end
check here. Since we're calculating a distance in a wrapping range, could it be end.wrapping_sub(start)
? Or I guess if we need to trim that to the type in question, size.truncate(end.wrapping_sub(start))
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(There's also something going weird here in general because the CI failure is here.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI failure is only for 128 bit discriminants with niches larger than i128::MAX because those turn negative
Got a fix and comments locally, just forgot to push
Thanks for fixing! Looks good. |
☀️ Test successful - checks-actions |
What is this?This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.Comparing c8bb4e8 (parent) -> 919c409 (this PR) Test differencesShow 6 test diffsStage 1
Stage 2
Additionally, 4 doctest diffs were found. These are ignored, as they are noisy. Job group index
Test dashboardRun cargo run --manifest-path src/ci/citool/Cargo.toml -- \
test-dashboard 919c40924373c248315a76618d8c52d39aed5e6e --output-dir test-dashboard And then open Job duration changes
How to interpret the job duration changes?Job durations can vary a lot, based on the actual runner instance |
Finished benchmarking commit (919c409): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)Results (primary -1.6%, secondary 0.8%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary 1.3%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 470.143s -> 468.849s (-0.28%) |
fixes #144388
r? @scottmcm