Skip to content

Commit 9a2c8fb

Browse files
qmuntaljohanbrandhorst
authored andcommitted
cmd/internal/obj/x86: use mov instead of lea to load the frame pointer
This CL instructs the Go x86 compiler to load the frame pointer address using a MOV instead of a LEA instruction, being MOV 1 byte shorter: Before 55 PUSHQ BP 48 8d 2c 24 LEAQ 0(SP), BP After 55 PUSHQ BP 48 89 e5 MOVQ SP, BP This reduces the size of the Go toolchain ~0.06%. Updates golang#6853 Change-Id: I5557cf34c47e871d264ba0deda9b78338681a12c Reviewed-on: https://go-review.googlesource.com/c/go/+/463845 Auto-Submit: Keith Randall <[email protected]> Reviewed-by: Keith Randall <[email protected]> Reviewed-by: Keith Randall <[email protected]> Run-TryBot: Quim Muntal <[email protected]> Reviewed-by: Cherry Mui <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent 307d62e commit 9a2c8fb

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/cmd/internal/obj/x86/obj6.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -695,11 +695,9 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
695695
// Move current frame to BP
696696
p = obj.Appendp(p, newprog)
697697

698-
p.As = ALEAQ
699-
p.From.Type = obj.TYPE_MEM
698+
p.As = AMOVQ
699+
p.From.Type = obj.TYPE_REG
700700
p.From.Reg = REG_SP
701-
p.From.Scale = 1
702-
p.From.Offset = 0
703701
p.To.Type = obj.TYPE_REG
704702
p.To.Reg = REG_BP
705703
}

0 commit comments

Comments
 (0)