As far as I am aware:

A LEA with a scale of 3 does not exist on amd64. Scale can be 1,2,4,8.

A LEA with 3 arguments LEAQ 4(AX)(AX*2) on many modern amd64 compatible 
machines will use 3 cycles instead of 2 for two simpler LEA.
The newest generation of Intel CPUs seems to have gotten better again 
avoiding slow LEA.

https://github.com/golang/go/issues/21735
https://github.com/golang/go/issues/31900

On Wednesday, August 26, 2020 at 5:04:15 AM UTC+2, xie cui wrote:
>
> function:
> func test3(a int) int {
>   return a * 3 + 4
> }
>
> go version go1.13.5 darwin/amd64
> generate instructions:
>   LEAQ    (AX)(AX*2), AX
>   LEAQ    4(AX), AX
>
> As far as i known,there a better choice
>  LEAQ    4(AX*3), AX
>
> Can it be optimized?
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/0d638194-eaf0-4b99-b66e-c831d8491470o%40googlegroups.com.

Reply via email to