I'm curious about why go 1.11 compiler is doing different things for
functions f1 and f2 in the following example:

type T [512]byte

//go:noinline
func use(*T) {}

func f1() {
   s := T{}
   use(&s)
}

func f2() {
   use(&T{})
}

T{} stays on the stack in both cases according to -gcflags=-m, but
benchmarking shows f1 to be almost twice as fast as f2. Looking at the
disassembly, f2 contains two DUFFZERO instructions, which I'm guessing
is what accounts for the performance difference. Why isn't the
compiler generating identical code here?

-Max

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to