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 coalesce loads that compare with constants #43248

josharian opened this issue Dec 17, 2020 · 0 comments


Copy link

@josharian josharian commented Dec 17, 2020

func f(x *[16]byte) bool {
	return x[0] == 0 && x[1] == 0 &&
		x[2] == 0 && x[3] == 0 &&
		x[4] == 0 && x[5] == 0 &&
		x[6] == 0 && x[7] == 0 &&
		x[8] == 0 && x[9] == 0 &&
		x[10] == 0xff && x[11] == 0xff

This could compile on amd64 to something like MOVQ to load the first 8 bytes, TESTQ to check whether the first 8 bytes are zero, MOVL to load the next 4 bytes, CMPL to test those bytes. Instead, we currently generate a series of 12 CMPBs.

Low priority.

@josharian josharian added this to the Unplanned milestone Dec 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.