This shaves a few bytes off here and there.
file before after Δ %
buildid
2865992 2861896 -4096 -0.143%
pprof
14744060 14739964 -4096 -0.028%
trace
11680644 11676548 -4096 -0.035%
vet
8448240 8444144 -4096 -0.048%
Change-Id: I799034afabc06a37b535301cd1380d63b4461095
Reviewed-on: https://go-review.googlesource.com/c/go/+/168343
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Martin Möhrmann <martisch@uos.de>
if p.As == AADJSP {
p.To.Type = obj.TYPE_REG
p.To.Reg = REG_SP
+ // Generate 'ADDQ $x, SP' or 'SUBQ $x, SP', with x positive.
+ // One exception: It is smaller to encode $-0x80 than $0x80.
+ // For that case, flip the sign and the op:
+ // Instead of 'ADDQ $0x80, SP', generate 'SUBQ $-0x80, SP'.
switch v := p.From.Offset; {
case v == 0:
p.As = obj.ANOP
- case v < 0:
+ case v == 0x80 || (v < 0 && v != -0x80):
p.As = spadjop(ctxt, AADDL, AADDQ)
p.From.Offset *= -1
default: