diff options
author | Josh Bleecher Snyder <josharian@gmail.com> | 2018-04-23 13:49:51 -0700 |
---|---|---|
committer | Josh Bleecher Snyder <josharian@gmail.com> | 2018-04-23 22:40:10 +0000 |
commit | d292f77e95fd9afdbfcfa12c9552d5926cdde8b1 (patch) | |
tree | 548e3d13213f820e0b37bf81abf9389221daa41f /test/codegen/arithmetic.go | |
parent | c0769741f541d2382c5c9b4506d684a738d7e53e (diff) | |
download | go-git-d292f77e95fd9afdbfcfa12c9552d5926cdde8b1.tar.gz |
cmd/compile: rewrite 2*x+c into LEAx1 on amd64
Rewrite x<<1+c into x+x+c, which can be expressed as a single LEAQ/LEAL.
Bit of a special case, but the single-instruction
LEA is both shorter and faster than SHL then ADD.
Triggers 293 times during make.bash.
Change-Id: I3f09c8e9a8f3859d1eeed336f095fc3ada79c2c1
Reviewed-on: https://go-review.googlesource.com/108938
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'test/codegen/arithmetic.go')
-rw-r--r-- | test/codegen/arithmetic.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/test/codegen/arithmetic.go b/test/codegen/arithmetic.go index ce7a7c27f4..3948ef301d 100644 --- a/test/codegen/arithmetic.go +++ b/test/codegen/arithmetic.go @@ -173,3 +173,8 @@ func CapMod(a []int) int { // amd64:"ANDQ\t[$]4095" return cap(a) % ((1 << 11) + 2048) } + +func AddMul(x int) int { + // amd64:"LEAQ\t1" + return 2*x + 1 +} |