Hi, I was surprised that the funcs f and g do not generate the same 
assembly code:

func f() string {
        s := "a" + "b"
        return s
}

func g() string {
        s := "a"
        s += "b"
        return s
}

The compiled assembly respects the apparent instructions of the source 
code, with g calling runtime.concatstring2, while f does not (f benefits 
from an optimization that transforms "a"+"b" into the constant "ab").

I don't know exactly what SSA does in the compiler, but I thought it would 
be capable of optimizing f and g into the exact same generated code. Am I 
missing something?

-- 
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/0646ffcb-cde2-4dd5-9f1c-e1cec1487b35n%40googlegroups.com.

Reply via email to