logoalt Hacker News

zipy124yesterday at 3:05 PM2 repliesview on HN

To those who don't know about compiler optimisation, the replacement with a closed form is rather suprising I'd say, especially if someone with Matt Godbolt's experience of all people is saying it is surprising.

Also this series is targeted towards more of a beginner audience to compilers, thus its likely to be suprising to the audience, even if not to you.


Replies

mattgriceyesterday at 6:27 PM

Gauss supposedly did it when he was 7. The hardest part for the compiler is figuring out that you have a loop that computes that sum and does nothing else important.

show 1 reply
CorrectHorseBatyesterday at 6:41 PM

It's something we saw in highschool, I would expect anyone with a CS degree to recognize this optimization.

I barely know anything about compiler optimization, so I have no clue whether a compiler applying this optimization is surprising or something trivial.

show 1 reply