]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: allow load-op merging in additional situations
authorKeith Randall <khr@golang.org>
Wed, 14 May 2025 23:00:25 +0000 (16:00 -0700)
committerKeith Randall <khr@golang.org>
Thu, 15 May 2025 22:21:36 +0000 (15:21 -0700)
commitd681270714bc91b28a2cd97c3eae138b3112ff1d
tree84173cf3cec16f007ac8c583c31021286e8f72bb
parenta88f093aaa35ae18aa02389624822101cbf231c0
cmd/compile: allow load-op merging in additional situations

x += *p

We want to do this with a single load+add operation on amd64.
The tricky part is that we don't want to combine if there are
other uses of x after this instruction.

Implement a simple detector that seems to capture a common situation -
x += *p is in a loop, and the other use of x is after loop exit.
In that case, it does not hurt to do the load+add combo.

Change-Id: I466174cce212e78bde83f908cc1f2752b560c49c
Reviewed-on: https://go-review.googlesource.com/c/go/+/672957
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
src/cmd/compile/internal/ssa/rewrite.go
test/codegen/memcombine.go