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 
>> would be capable of optimizing f and g into the exact same generated code. 
>> Am I missing something?
>>
>
> Roughly, SSA would rewrite the g() function to something along the lines of
>
> func g() string {
>         s1 := "a"
>         s2 = s1 + "b"
>         return s
> }
>
> That is, it would make it easier to figure out where s1 is defined (since 
> it can only have a single static assignment in the program, we don't have 
> to worry if there is another path defining s := "x"). Yet, this is not a 
> guarantee for optimization. You still have to carry out an analysis for 
> when an optimization is safe to apply. The key point is that such an 
> analysis is far easier to perform in SSA-form. Furthermore, it is often 
> more efficient, so the compiler runs faster. My haphazard guess would be 
> that constant/value propagation happens for number-types but not for 
> strings.
>
>
>
> -- 
> 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/03b5650f-3e55-4c6d-aa28-5de3ad65c6c5n%40googlegroups.com.

Reply via email to