On Sat, May 1, 2021 at 1:28 PM Jesper Louis Andersen <
jesper.louis.ander...@gmail.com> wrote:
>
> func g() string {
> s1 := "a"
> s2 = s1 + "b"
> return s
> }
>
>
Errata: it should have been `return s2` rather than `return s`. I hope I
didn't confuse people too much.
--
Thank you all for the insights
On Saturday, May 1, 2021 at 1:29:15 PM UTC+2 jesper.lou...@gmail.com wrote:
> On Fri, Apr 30, 2021 at 7:51 PM 'Valentin Deleplace' via golang-nuts <
> golan...@googlegroups.com> wrote:
>
>> I don't know exactly what SSA does in the compiler, but I thought it
>> wou
On Fri, Apr 30, 2021 at 7:51 PM 'Valentin Deleplace' via golang-nuts <
golang-nuts@googlegroups.com> wrote:
> 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?
>
Roughly, SSA
On Fri, Apr 30, 2021 at 10:51 AM 'Valentin Deleplace' via golang-nuts
wrote:
>
> 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"
>
On Fri, Apr 30, 2021 at 7:51 PM 'Valentin Deleplace' via golang-nuts
wrote:
> func f() string {
> s := "a" + "b"
> return s
> }
Handled by constant folding.
> func g() string {
> s := "a"
> s += "b"
> return s
> }
The second assignment to 's' here is not
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, wit