-
Notifications
You must be signed in to change notification settings - Fork 13.3k
In simplify_repeated_aggregate
, don't test first element against itself
#139411
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
Could not assign reviewer from: |
rustbot has assigned @petrochenkov. Use |
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
@@ -78,20 +78,20 @@ impl<'tcx> InstSimplifyContext<'_, 'tcx> { | |||
/// GVN can also do this optimization, but GVN is only run at mir-opt-level 2 so having this in | |||
/// InstSimplify helps unoptimized builds. | |||
fn simplify_repeated_aggregate(&self, rvalue: &mut Rvalue<'tcx>) { | |||
let Rvalue::Aggregate(box AggregateKind::Array(_), fields) = rvalue else { | |||
let Rvalue::Aggregate(box AggregateKind::Array(_), fields) = &*rvalue else { |
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 is just so fields
is immutable, which makes it a bit easier to reason about, IMHO.
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
…ify, r=<try> In `simplify_repeated_aggregate`, don't test first element against itself r? `@saethlin` Noticed that in `InstSimplifyContext::simplify_repeated_aggregate`, we're accidentally evaluating the first element's value twice, and then comparing it with itself, instead of just checking whether the rest of the elements are equal to the first one. This will probably save very few cycles, but since `InstSimplify` is always enabled, this might improve perf by a bit.
r=me (i.e. I will approve) when perf comes back. |
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (fa2c9b1): comparison URL. Overall result: no relevant changes - no action neededBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. @bors rollup=never Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)This benchmark run did not return any relevant results for this metric. CyclesResults (secondary 2.3%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 776.909s -> 777.668s (0.10%) |
@bors r+ rollup- |
☀️ 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 c211076 (parent) -> 1de9312 (this PR) Test differencesNo test diffs found 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 (1de9312): 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 (secondary -3.3%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 775.586s -> 775.764s (0.02%) |
…ify/simplify_primitive_clone, r=<try> Micro-optimize `InstSimplify`'s `simplify_primitive_clone` r? `@compiler-errors` , since you already did rust-lang#139411 and got randomly selected for rust-lang#139638 (feel free to reassign!) Another one similar in spirit to rust-lang#139411, but this time for `simplify_primitive_clone`, which is doing a bit of redundant work. Might not show up in benches, but probably worth micro-optimizing since the transformation is run even for debug builds. See inline comments for my reasoning for making these changes.
…plify/cleanup, r=oli-obk Cleanup the `InstSimplify` MIR transformation Some minor cleanups and rightward-drift-protection found while working on rust-lang#139411 and a future follow-up
Rollup merge of rust-lang#139638 - yotamofek:pr/mir_transform/instsimplify/cleanup, r=oli-obk Cleanup the `InstSimplify` MIR transformation Some minor cleanups and rightward-drift-protection found while working on rust-lang#139411 and a future follow-up
…plify/simplify_primitive_clone, r=compiler-errors Micro-optimize `InstSimplify`'s `simplify_primitive_clone` r? `@compiler-errors` , since you already did rust-lang#139411 and got randomly selected for rust-lang#139638 (feel free to reassign!) Another one similar in spirit to rust-lang#139411, but this time for `simplify_primitive_clone`, which is doing a bit of redundant work. Might not show up in benches, but probably worth micro-optimizing since the transformation is run even for debug builds. See inline comments for my reasoning for making these changes.
…plify/simplify_primitive_clone, r=compiler-errors Micro-optimize `InstSimplify`'s `simplify_primitive_clone` r? ``@compiler-errors`` , since you already did rust-lang#139411 and got randomly selected for rust-lang#139638 (feel free to reassign!) Another one similar in spirit to rust-lang#139411, but this time for `simplify_primitive_clone`, which is doing a bit of redundant work. Might not show up in benches, but probably worth micro-optimizing since the transformation is run even for debug builds. See inline comments for my reasoning for making these changes.
…plify/simplify_primitive_clone, r=compiler-errors Micro-optimize `InstSimplify`'s `simplify_primitive_clone` r? ```@compiler-errors``` , since you already did rust-lang#139411 and got randomly selected for rust-lang#139638 (feel free to reassign!) Another one similar in spirit to rust-lang#139411, but this time for `simplify_primitive_clone`, which is doing a bit of redundant work. Might not show up in benches, but probably worth micro-optimizing since the transformation is run even for debug builds. See inline comments for my reasoning for making these changes.
…plify/simplify_primitive_clone, r=compiler-errors Micro-optimize `InstSimplify`'s `simplify_primitive_clone` r? ````@compiler-errors```` , since you already did rust-lang#139411 and got randomly selected for rust-lang#139638 (feel free to reassign!) Another one similar in spirit to rust-lang#139411, but this time for `simplify_primitive_clone`, which is doing a bit of redundant work. Might not show up in benches, but probably worth micro-optimizing since the transformation is run even for debug builds. See inline comments for my reasoning for making these changes.
Rollup merge of rust-lang#139644 - yotamofek:pr/mir_transform/instsimplify/simplify_primitive_clone, r=compiler-errors Micro-optimize `InstSimplify`'s `simplify_primitive_clone` r? ````@compiler-errors```` , since you already did rust-lang#139411 and got randomly selected for rust-lang#139638 (feel free to reassign!) Another one similar in spirit to rust-lang#139411, but this time for `simplify_primitive_clone`, which is doing a bit of redundant work. Might not show up in benches, but probably worth micro-optimizing since the transformation is run even for debug builds. See inline comments for my reasoning for making these changes.
r? @saethlin
Noticed that in
InstSimplifyContext::simplify_repeated_aggregate
, we're accidentally evaluating the first element's value twice, and then comparing it with itself, instead of just checking whether the rest of the elements are equal to the first one.This will probably save very few cycles, but since
InstSimplify
is always enabled, this might improve perf by a bit.