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/compile: merging shifts into loads/stores isn't complete #36223
Comments
I did some related work in https://go-review.googlesource.com/c/go/+/167089 and https://go-review.googlesource.com/c/go/+/167090. I have better tooling now, so I may try to improve these and try again for 1.15. However, I don't think we handle commutative ops any more efficiently yet. Do you have plans to work on this? I've been contemplating different approaches. |
I have not made any plans yet. Go for it. |
Change https://golang.org/cl/213704 mentions this issue: |
I mailed CLs 213697-213704. They start with cleanup and improvement with the existing commutativity regime, then replace it. There's probably more to do here, but I've blown through the time I allotted to this. I'll file issues for follow-up ideas. |
I write in the CL “may fix” this issue. GitHub ignored the first word. :P Leaving to @randall77 to decide what else needs to happen to declare this fixed. |
This is fixed with CL 217097. |
The compiler generates code like this:
We can use the
(AX*8)
indexing mode and get rid of the shift.There is already code to do this in the compiler. However, it doesn't fire in this case, as the shift amount is in the "wrong" arugment slot.
The SSA representation is (MOVQstoreconstidx1 [5] (SHLQconst [3] v) x y). Normally these rules are written to expect the pointer first, then the shifted index, so it does not fire in this case (shifted index first, then pointer).
We should mark ops like these as commutative on the first two args, so the rewrite engine will detect this correctly. There is even a comment in the rule file:
I think our rewrite engine now handles commutative ops more efficiently, so possibly not an issue anymore. Investigate, and do it.
The text was updated successfully, but these errors were encountered: