-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Add an InstSimplify for repetitive array expressions #135274
Conversation
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
@bors try |
Add an InstSimplify for repetitive array expressions r? ghost Let's see if this even perfs well.
⌛ Trying commit d767dd8 with merge 9811408f4eb6418d113324d8e3609a0a84b54664... |
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (9811408): comparison URL. Overall result: ✅ improvements - 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 is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.
Max RSS (memory usage)Results (primary 2.8%, secondary -11.7%)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.
CyclesResults (secondary -28.4%)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 sizeResults (secondary -25.2%)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.
Bootstrap: 764.798s -> 763.387s (-0.18%) |
d767dd8
to
be5157b
Compare
This comment has been minimized.
This comment has been minimized.
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
r? mir-opt |
let Operand::Constant(field) = field else { | ||
return false; | ||
}; | ||
let field = field.const_.eval(self.tcx, self.typing_env, field.span); |
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.
Would be cool to see more tests exercising this eval call. Specifically, maybe something like [CONST, CONST, ...]
for some global const, something with ZSTs, something gauging whether or not it works with things like nested slices/string lits (probably doesn't? const eval doesn't deduplicate allocations like that right?)
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.
The optimization doesn't work on ZSTs. Ultimately that doesn't matter because RemoveZsts will run before InstSimplify and completely eliminate the statement we would optimize.
But it makes me a bit worried that this doesn't work with ZSTs because we generate a local per array element for ZSTs, but we don't for a numeric literal, and this optimization relies on generating an Operand::Const, not a local per array element that we then Move from.
be5157b
to
1c9902e
Compare
This comment has been minimized.
This comment has been minimized.
1c9902e
to
a285d20
Compare
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.
ty for the tests
r=me
r? compiler-errors |
🌲 The tree is currently closed for pull requests below priority 1000. This pull request will be tested once the tree is reopened. |
☀️ Test successful - checks-actions |
Finished benchmarking commit (7e4077d): comparison URL. Overall result: ✅ improvements - no action needed@rustbot label: -perf-regression Instruction countThis is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.
Max RSS (memory usage)Results (secondary -12.1%)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.
CyclesResults (secondary -18.2%)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 sizeResults (secondary -25.2%)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.
Bootstrap: 763.776s -> 765.598s (0.24%) |
Use Box::new instead of the box_new intrinsic in vec! expansion r? ghost This should perf differently since rust-lang#135274 landed. Some UI tests are failing locally and seem to indicate a diagnostic regression that I'll fix if this perfs well.
I noticed in #135068 (comment) that GVN's implementation of this same transform was quite profitable on the deep-vector benchmark. But of course GVN doesn't run in unoptimized builds, so this is my attempt to write a version of this transform that benefits the deep-vector case and is fast enough to run in InstSimplify.
The benchmark suite indicates that this is effective.