diff options
| author | Michael Munday <munday@ca.ibm.com> | 2016-10-06 15:06:45 -0400 |
|---|---|---|
| committer | Michael Munday <munday@ca.ibm.com> | 2016-10-11 18:52:35 +0000 |
| commit | 15817e409bce6eeaa7ea2ae158db6ce4618f27f2 (patch) | |
| tree | d4adf772de90d6201238dabb72fbb111f2532c7f /src/cmd/compile/internal/ssa/regalloc.go | |
| parent | 809a1de1ac1ccc76f7a4faf630017626f2f68231 (diff) | |
| download | go-15817e409bce6eeaa7ea2ae158db6ce4618f27f2.tar.xz | |
cmd/compile: make link register allocatable in non-leaf functions
We save and restore the link register in non-leaf functions because
it is clobbered by CALLs. It is therefore available for general
purpose use.
Only enabled on s390x currently. The RC4 benchmarks in particular
benefit from the extra register:
name old speed new speed delta
RC4_128 243MB/s ± 2% 341MB/s ± 2% +40.46% (p=0.008 n=5+5)
RC4_1K 267MB/s ± 0% 359MB/s ± 1% +34.32% (p=0.008 n=5+5)
RC4_8K 271MB/s ± 0% 362MB/s ± 0% +33.61% (p=0.008 n=5+5)
Change-Id: Id23bff95e771da9425353da2f32668b8e34ba09f
Reviewed-on: https://go-review.googlesource.com/30597
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Michael Munday <munday@ca.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/ssa/regalloc.go')
| -rw-r--r-- | src/cmd/compile/internal/ssa/regalloc.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/ssa/regalloc.go b/src/cmd/compile/internal/ssa/regalloc.go index 8309af2997..4180868932 100644 --- a/src/cmd/compile/internal/ssa/regalloc.go +++ b/src/cmd/compile/internal/ssa/regalloc.go @@ -460,6 +460,18 @@ func (s *regAllocState) allocValToReg(v *Value, mask regMask, nospill bool, line return c } +// isLeaf reports whether f performs any calls. +func isLeaf(f *Func) bool { + for _, b := range f.Blocks { + for _, v := range b.Values { + if opcodeTable[v.Op].call { + return false + } + } + } + return true +} + func (s *regAllocState) init(f *Func) { s.f = f s.registers = f.Config.registers @@ -510,6 +522,12 @@ func (s *regAllocState) init(f *Func) { s.allocatable &^= 1 << 12 // R12 } } + if s.f.Config.LinkReg != -1 { + if isLeaf(f) { + // Leaf functions don't save/restore the link register. + s.allocatable &^= 1 << uint(s.f.Config.LinkReg) + } + } if s.f.Config.ctxt.Flag_dynlink { switch s.f.Config.arch { case "amd64": |
