various go-assembler code is generated

124 views
Skip to first unread message

Паша Бурак

unread,
Jul 13, 2021, 5:51:32 PM7/13/21
to golang-nuts
https://go.godbolt.org/z/G8K79K48G - small
https://go.godbolt.org/z/Yv853E6P3 - long

>go version go1.16 windows/amd64

On the local machine i am executing  go tool compile -S main.go > main.s

in the second case, I see that the compiler sees here a local variable entering the code. Why is this happening ? why is such a different code generated?

Keith Randall

unread,
Jul 13, 2021, 7:27:55 PM7/13/21
to golang-nuts
The Go compiler is not very good at eliminating redundant copies of large temporaries (structs with many fields, or arrays with length>1).
Reply all
Reply to author
Forward
0 new messages