-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Fix optimization regressions for operations on [x; n]-initialized arrays. #36124
Conversation
r? @aturon (rust_highfive has picked a reviewer for you, use r? to override) |
☔ The latest upstream changes (presumably #36117) made this pull request unmergeable. Please resolve the merge conflicts. |
Nice find. It should be much better this way, the optimizer prefers < / <= for an integer-counted loop and != for a pointer loop. |
@bluss You sure? Overflow shenanigans apply to both pointers and integers. |
Ok I've merged the LLVM commit, @eddyb wanna update the commit here? |
@bors: r+ |
📌 Commit f5c7752 has been approved by |
⌛ Testing commit f5c7752 with merge 2c7fd85... |
💔 Test failed - auto-win-gnu-32-opt-rustbuild |
@bors: retry On Fri, Sep 2, 2016 at 8:31 AM, bors [email protected] wrote:
|
⌛ Testing commit f5c7752 with merge 1ca1de6... |
Fix optimization regressions for operations on [x; n]-initialized arrays. Fixes #35662 by using `!=` instead of `<` as the stop condition for `[x; n]` initialization loops. Also included is eddyb/llvm@cc2009f, a hack to run the GVN pass twice, another time after InstCombine. This hack results in removal of redundant `memset` and `memcpy` calls (from loops over arrays). cc @nrc Can we get performance numbers on this? Not sure if it regresses anything else.
@alexcrichton @nrc @nikomatsakis This caused a 4% regression in bootstrap. Hopefully it's worth it. |
The patch is tiny. I think it's worth backporting. I don't know what to make of the 4% regression. Could be a lot of things. cc @rust-lang/compiler |
From skimming the perf benchmarks (rather than bootstrap) times, I think we can accept the risk associated with backporting this.
|
@@ -52,7 +52,7 @@ pub fn slice_for_each<'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>, | |||
let current = Phi(header_bcx, val_ty(start), &[start], &[bcx.llbb]); | |||
|
|||
let keep_going = | |||
ICmp(header_bcx, llvm::IntULT, current, end, DebugLoc::None); |
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 the only line that has to be applied to beta for backport.
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.
Without the LLVM change the regression isn't fully fixed, but yeah, this is the main part of it.
It might be in different places, so searching for IntULT
used in an iteration loop condition should help.
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.
Beta is on LLVM commit further ahead now due to previous backport.
OK, I will go ahead and mark as beta-accepted. Backporter should note that backport can be quite minimum, per @nagisa's comments here. |
I've started a backport. |
Fixes #35662 by using
!=
instead of<
as the stop condition for[x; n]
initialization loops.Also included is eddyb/llvm@cc2009f, a hack to run the GVN pass twice, another time after InstCombine.
This hack results in removal of redundant
memset
andmemcpy
calls (from loops over arrays).cc @nrc Can we get performance numbers on this? Not sure if it regresses anything else.