mirror of
https://github.com/golang/go
synced 2024-11-25 11:07:59 -07:00
e0ceba8139
[This is a roll-forward of CL 458755, which was reverted due to make.bash being broken on GOAMD64=v3. But it turned out that the problem was caused by wrong bswap/load rewrite rules, and it was fixed in CL 492616.] 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: I36ea68bed384986cd3ae81cb9e6efe84bb213adc Reviewed-on: https://go-review.googlesource.com/c/go/+/492895 Reviewed-by: Keith Randall <khr@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com> Reviewed-by: Keith Randall <khr@google.com> Run-TryBot: Eric Fang <eric.fang@arm.com>
23 lines
513 B
Go
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$"
|
|
}
|
|
}
|