Re:Mugo, a toy compiler for a subset of Go that can compile ...
by thysultan on Monday April 12, 2021 @08:07AM
(#26778445)
NodeJs and Go can and probably are optimizing the loop away, the authors attempt to assign the sum to result does not prevent this from happening.
[ Parent
| on HN ]
Re:Mugo, a toy compiler for a subset of Go that can compile ...
by benhoyt on Monday April 12, 2021 @03:00PM
(#26783606)
> can and probably are optimizing the loop away
Why do you think that, and how would it do that and still do the calculation? My timing tests showed that Go didn't optimize the loop away (if I counted to 10 billion it took about 10 times as long), and godbolt.org also shows the loop in Go's assembly output: https://www.godbolt.org/z/d38xfGYr6