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

Open
josharian opened this issue Dec 17, 2020 · 0 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Performance
Milestone

Comments

@josharian
Copy link
Contributor

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
@cagedmantis cagedmantis added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Dec 21, 2020
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Performance
Projects
None yet
Development

No branches or pull requests

3 participants