go/test/tighten.go
erifan01 ea8f037996 cmd/compile: enhance tighten pass for memory values
This CL enhances the tighten pass. Previously if a value has memory arg,
then the tighten pass won't move it, actually if the memory state is
consistent among definition and use block, we can move the value. This
CL optimizes this case. This is useful for the following situation:
b1:
  x = load(...mem)
  if(...) goto b2 else b3
b2:
  use(x)
b3:
  some_op_not_use_x

For the micro-benchmark mentioned in #56620, the performance improvement
is about 15%.
There's no noticeable performance change in the go1 benchmark.

Fixes #56620

Change-Id: I9b152754f27231f583a6995fc7cd8472aa7d390c
Reviewed-on: https://go-review.googlesource.com/c/go/+/458755
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
2023-05-03 19:56:09 +00:00

23 lines
513 B
Go

// errorcheck -0 -d=ssa/tighten/debug=1
//go:build arm64
// Copyright 2023 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
var (
e any
ts uint16
)
func moveValuesWithMemoryArg(len int) {
for n := 0; n < len; n++ {
// Load of e.data is lowed as a MOVDload op, which has a memory
// argument. It's moved near where it's used.
_ = e != ts // ERROR "MOVDload is moved$" "MOVDaddr is moved$"
}
}