mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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>
This commit is contained in:
parent
c486f74eeb
commit
ea8f037996
3 changed files with 127 additions and 7 deletions
|
|
@ -602,6 +602,11 @@ func isLeaf(f *Func) bool {
|
|||
return true
|
||||
}
|
||||
|
||||
// needRegister reports whether v needs a register.
|
||||
func (v *Value) needRegister() bool {
|
||||
return !v.Type.IsMemory() && !v.Type.IsVoid() && !v.Type.IsFlags() && !v.Type.IsTuple()
|
||||
}
|
||||
|
||||
func (s *regAllocState) init(f *Func) {
|
||||
s.f = f
|
||||
s.f.RegAlloc = s.f.Cache.locs[:0]
|
||||
|
|
@ -702,7 +707,7 @@ func (s *regAllocState) init(f *Func) {
|
|||
s.copies = make(map[*Value]bool)
|
||||
for _, b := range s.visitOrder {
|
||||
for _, v := range b.Values {
|
||||
if !v.Type.IsMemory() && !v.Type.IsVoid() && !v.Type.IsFlags() && !v.Type.IsTuple() {
|
||||
if v.needRegister() {
|
||||
s.values[v.ID].needReg = true
|
||||
s.values[v.ID].rematerializeable = v.rematerializeable()
|
||||
s.orig[v.ID] = v
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue