]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/obj/arm64: optimize stacksplit prologue for small stack
authoreric fang <eric.fang@arm.com>
Tue, 18 Jan 2022 08:49:56 +0000 (08:49 +0000)
committerEric Fang <eric.fang@arm.com>
Tue, 8 Mar 2022 02:01:53 +0000 (02:01 +0000)
When framesize <= objabi.StackSmall, 128B, the stacksplit prologue is:
  MOVD 16(g), R16
  MOVD SP, R17
  CMP R16, R17
  BLS morestack_label

The second instruction is not necessary, we can compare R16 with SP
directly, so the sequence becomes:
  MOVD 16(g), R16
  CMP R16, SP
  BLS morestack_label

This CL removes this instruction.

Change-Id: I0567ac52e9be124880957271951e1186da203612
Reviewed-on: https://go-review.googlesource.com/c/go/+/379076
Trust: Eric Fang <eric.fang@arm.com>
Run-TryBot: Eric Fang <eric.fang@arm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Eric Fang <eric.fang@arm.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
src/cmd/internal/obj/arm64/obj7.go

index e9eb786cb24f602fd21c218731743a3e08a657ce..2bbc7e37b0b988cc4bafb350d64e5112e82974cb 100644 (file)
@@ -165,21 +165,13 @@ func (c *ctxt7) stacksplit(p *obj.Prog, framesize int32) *obj.Prog {
        q := (*obj.Prog)(nil)
        if framesize <= objabi.StackSmall {
                // small stack: SP < stackguard
-               //      MOV     SP, RT2
-               //      CMP     stackguard, RT2
-               p = obj.Appendp(p, c.newprog)
-
-               p.As = AMOVD
-               p.From.Type = obj.TYPE_REG
-               p.From.Reg = REGSP
-               p.To.Type = obj.TYPE_REG
-               p.To.Reg = REGRT2
+               //      CMP     stackguard, SP
 
                p = obj.Appendp(p, c.newprog)
                p.As = ACMP
                p.From.Type = obj.TYPE_REG
                p.From.Reg = REGRT1
-               p.Reg = REGRT2
+               p.Reg = REGSP
        } else if framesize <= objabi.StackBig {
                // large stack: SP-framesize < stackguard-StackSmall
                //      SUB     $(framesize-StackSmall), SP, RT2