cmd/compile: improve generated eq algs for structs containing strings
cmd/compile: improve generated eq algs for structs containing strings

type T struct {
    s string
    i int
}

Prior to this change, we generated this equality algorithm for T:

func eqT(p, q *T) bool {
    return len(p.s) == len(q.s) &&
      runtime.memequal(p.s.ptr, q.s.ptr, len(p.s)) &&
      p.i == q.i
}

This change splits the two halves of the string equality,
so that we can do the cheap (length) half early and the expensive
(contents) half late. We now generate:

func eqT(p, q *T) bool {
    return len(p.s) == len(q.s) &&
      p.i == q.i &&
      runtime.memequal(p.s.ptr, q.s.ptr, len(p.s))
}

The generated code for these functions tends to be a bit shorter. Examples:

runtime
.eq."".Frame 274 -> 272  (-0.73%)
.eq."".funcinl 249 -> 247  (-0.80%)
.eq."".modulehash 207 -> 205  (-0.97%)

Change-Id: I4efac9f7d410f0a11a94dcee2bf9c0b49b60e301
Reviewed-on: https://go-review.googlesource.com/c/go/+/230205
Run-TryBot: Josh Bleecher Snyder <cdc248cc4d32e4fbfe04e45228163bcecd48a0b9@gmail.com>
TryBot-Result: Gobot Gobot <66cb808b70d30c07676d5e946fee83fd561249e5@golang.org>
Reviewed-by: Brad Fitzpatrick <ae9783c0b0efc69cd85ab025ddd17aa44cdc4aa5@golang.org>

akutz/go,CAFxX/go,CAFxX/go,CAFxX/go,CAFxX/go,akutz/go,golang/go,golang/go,CAFxX/go,nawawi/go,cloudflare/go,cloudflare/go,nawawi/go,CAFxX/go,cloudflare/go,akutz/go,akutz/go,cloudflare/go,cloudflare/go,CAFxX/go,nawawi/go,akutz/go,nawawi/go,golang/go,golang/go,cloudflare/go,akutz/go,cloudflare/go,golang/go,cloudflare/go,nawawi/go,CAFxX/go,nawawi/go,akutz/go,golang/go,nawawi/go,nawawi/go,golang/go,akutz/go,golang/go