-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
GVN: Elide more intermediate transmutes #151622
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
|
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
|
I'm not expecting much, but just in case: |
This comment has been minimized.
This comment has been minimized.
GVN: Elide more intermediate transmutes
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (cd2b201): comparison URL. Overall result: ❌✅ regressions and improvements - please read the text belowBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary -4.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeResults (primary -0.0%, secondary -0.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 471.746s -> 470.956s (-0.17%) |
This comment has been minimized.
This comment has been minimized.
| // as it's just there to convey the validity invariant. | ||
| // (Hopefully it'll eventually be a pattern type instead.) | ||
| _inner_repr_trick: AlignmentEnum, | ||
| } |
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.
Can this change be done in its own commit? This would make easier to understand what changes from the mir opt diff.
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.
Absolutely. I split it to three:
- Just the compiler change to the mir-opt pass
- The change to
Alignment::as_usizeon its own - The field change in
Alignment
That way all the library changes are separated.
| } else if let Ok(from_layout) = self.ecx.layout_of(from_ty) | ||
| && !from_layout.uninhabited | ||
| && from_layout.size == middle_layout.size | ||
| && let BackendRepr::Scalar(from_a) = from_layout.backend_repr | ||
| && let a_range = a.valid_range(&self.ecx) | ||
| && let from_range = from_a.valid_range(&self.ecx) | ||
| && a_range.contains_range(from_range, middle_layout.size) | ||
| { | ||
| false | ||
| } else if let Ok(to_layout) = self.ecx.layout_of(to_ty) | ||
| && !to_layout.uninhabited | ||
| && to_layout.size == middle_layout.size | ||
| && let BackendRepr::Scalar(to_a) = to_layout.backend_repr | ||
| && let a_range = a.valid_range(&self.ecx) | ||
| && let to_range = to_a.valid_range(&self.ecx) | ||
| && a_range.contains_range(to_range, middle_layout.size) | ||
| { | ||
| false |
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.
Do you mind commenting the logic? This looks good to me, but it took me a few frowns to understand, for instance why ranges are compared the way you wrote it
433703d to
9288c20
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
@bors r+ |
This comment has been minimized.
This comment has been minimized.
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 8afe9ff (parent) -> 905b926 (this PR) Test differencesShow 22 test diffs22 doctest diffs were found. These are ignored, as they are noisy. Test dashboardRun cargo run --manifest-path src/ci/citool/Cargo.toml -- \
test-dashboard 905b9269674ced4b5239f485609a3bf0ab02d01b --output-dir test-dashboardAnd 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 (905b926): comparison URL. Overall result: ❌✅ regressions and improvements - no action needed@rustbot label: -perf-regression Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 1.4%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary 2.8%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary -0.1%, secondary -0.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 476.06s -> 477.374s (0.28%) |
We already skipped intermediate steps like
u32ori32that support any (initialized) value.This extends that to also allow skipping intermediate steps whose values are a superset of either the source or destination type. Most importantly, that means that
usize→NonZeroUsize→ptr::Alignmentandptr::Alignment→NonZeroUsize→usizecan skip the middle becauseNonZeroUsizeis a superset ofAlignment.Then
Alignment::as_usizeis updated to take advantage of that and let us remove some more locals in a few places.r? cjgillot