]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: rewrite 2*x+c into LEAx1 on amd64
authorJosh Bleecher Snyder <josharian@gmail.com>
Mon, 23 Apr 2018 20:49:51 +0000 (13:49 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Mon, 23 Apr 2018 22:40:10 +0000 (22:40 +0000)
commitd292f77e95fd9afdbfcfa12c9552d5926cdde8b1
tree548e3d13213f820e0b37bf81abf9389221daa41f
parentc0769741f541d2382c5c9b4506d684a738d7e53e
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>
src/cmd/compile/internal/ssa/gen/AMD64.rules
src/cmd/compile/internal/ssa/rewriteAMD64.go
test/codegen/arithmetic.go