Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
cmd/compile: optimize small runtime.memequal calls #37275
In the SSA backend, we could optimize a call to runtime.memequal in which the length is small and one argument points to a readonly data symbol. We could replace it by reading the readonly data and checking the bytes of the other argument directly.
This is similar to the optimization in walk.go for comparing against a constant string, and could potentially supercede it. The optimization in walk.go doesn't always trigger. An example is using strings.HasPrefix to check for a constant prefix; the call gets inlined, but walk.go isn't able to do the optimization because its analysis isn't powerful enough.