On Wed, Sep 23, 2020 at 10:09 AM cs.ali...@gmail.com <
cs.alikoyu...@gmail.com> wrote:

> Is there a paper that I can find why the compiler considers them for
> ordering, why it is important for performance or anything else?
>
>
A CPU has a limit to how many load/store instructions it can issue in a
given clock cycle or in a given window of clock cycles. By reordering
memory loads, you can spread them out such that they don't create conflicts
against each other. This covers the part of memory ordering optimizations.
As for function calls, you often have a call convention where some
registers are saved by the caller and some registers are saved by the
callee. Hence it can be beneficial to arrange the evaluation order in a way
to avoid having to save registers. I think Go's current ABI rules are to
use the stack for everything in its calling convention, but the same
general rules apply: you may want to reorder the work in order to save on
register pressure. It becomes especially interesting if your calling
convention allows for multiple return values passed in registers.

Note that
https://go.googlesource.com/proposal/+/refs/changes/78/248178/1/design/40724-register-calling.md
proposes a register-based calling convention for the Go compiler, which
hammers through the need of flexibility in this area.

-- 
J.

-- 
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/CAGrdgiXN5k_d8MY1KyPK7E3i0WkjCK-wHNxi6phuAVWE2SOoOg%40mail.gmail.com.

Reply via email to