Skip to content
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: missed opportunity to inline runtime.memmove #41662

Open
josharian opened this issue Sep 27, 2020 · 0 comments
Open

cmd/compile: missed opportunity to inline runtime.memmove #41662

josharian opened this issue Sep 27, 2020 · 0 comments

Comments

@josharian
Copy link
Contributor

@josharian josharian commented Sep 27, 2020

package p

func f(b []byte, x *[8]byte) {
	_ = b[8]
	copy(b, x[:])
}

This should compile down to a pair of MOVQs, one to load from x and one to write to b. It doesn't; it still contains a call to runtime.memmove. From a quick glance at ssa.html, the problem is that the lowering of runtime.memmove to Move happens during generic.rules, but we haven't detected that the size of the memmove is a constant until after lowering.

To fix this, we could either improve the analysis in the generic stages or add arch-specific runtime.memmove-to-Move lowering.

cc @randall77 @dr2chase @martisch @mundaym

@josharian josharian added this to the Unplanned milestone Sep 27, 2020
@andybons andybons added the NeedsFix label Sep 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.