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
cmd/internal: add align directive to enhance performance #14935
Comments
What if we just align every label that is the target of a backward jump?
|
Note that current SSA policy for judged-rare if-thens is (I am pretty sure, been looking at code just today) is to branch to the end, then branch back, which would introduce a lot of alignments where they'd not be that profitable and might just take up space. (This might have an annoying effect on linear-scan register allocation, I need to look into that). |
I note for the record that GCC has the following options:
Surprisingly, GCC does not have -falign-likely-jumps, which would align all labels that can be reached only by jumps, ignoring jumps considered to be unlikely. That is probably the option we want by default, along with -falign-loops. |
I agree with the previous concern about backward branches. Perhaps there is a way to mark the branch targets that were the result of backward branches before any kind of code straightening or rearranging was done by SSA? . |
I think the original suggestion of a new opcode is not a bad one. The SSA code that does the (de-)straightening knows where the loops are. If we do profiling, that will be even better information (that will be useful for everything from block ordering to register allocation, never mind label alignment). |
With an opcode/directive there could be a field that specified the alignment, which would make it more flexible. |
Change https://golang.org/cl/144218 mentions this issue: |
Please answer these questions before submitting your issue. Thanks!
go version
)?go version devel +baec148 Wed Mar 23 14:21:15 2016 +0000 linux/ppc64
go env
)?linux ppc64le
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
As a result of some performance analysis it was found that some code generated
as a result of plan9 asm does not perform as well as it could because the high use
loops do not have the preferred alignment with respect to the icache.
I have a change to add a new opcode(a directive actually) to indicate that the code stream should be aligned to a certain value at that point. That way the directive can be inserted before a significant loop and allow the loop body to remain in the icache during execution resulting in better performance.
The text was updated successfully, but these errors were encountered: