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: suboptimal code for string equality #59684

Closed
randall77 opened this issue Apr 17, 2023 · 1 comment
Closed

cmd/compile: suboptimal code for string equality #59684

randall77 opened this issue Apr 17, 2023 · 1 comment
Assignees
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FrozenDueToAge Performance
Milestone

Comments

@randall77
Copy link
Contributor

The optimizations of string equality are somewhat fragile. Particularly, the optimization of deciding when we don't need the full generality of memequal and can do something better instead.

The ordering of equality can make a difference, when it really shouldn't. Some orderings generate a memequal call, and some don't.

Compares that are obviously constant-sized, like those against the empty string, can sometimes still generate memequal calls.

Noticed as part of the truthy benchmarks, mentioned here.

@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Apr 17, 2023
@randall77 randall77 self-assigned this Apr 17, 2023
@randall77 randall77 added this to the Go1.21 milestone Apr 17, 2023
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/485535 mentions this issue: cmd/compile: remove memequal call from string compares in more cases

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FrozenDueToAge Performance
Projects
None yet
Development

No branches or pull requests

2 participants