Remix.run Logo
Advent of Compiler Optimisations 2025(xania.org)
175 points by vismit2000 5 hours ago | 15 comments
bspammer 3 hours ago | parent | next [-]

I really appreciate that despite being an obvious domain expert, he’s starting with the simple stuff and not jumping straight into crazy obscure parts of the x86 instruction set

adev_ 2 hours ago | parent | prev | next [-]

Matt Godbolt is an absolute gem for the C & C++ community.

Many thanks to him for that.

Between that and compiler explorer, it is fair to say he made the world a better place for many of us, developers.

alberth an hour ago | parent | prev | next [-]

After 25-years of software development, I still wonder whether I’m using the best possible compiler flags.

cogman10 41 minutes ago | parent [-]

What I've learned is that the fewer flags is the best path for any long lived project.

-O2 is basically all you usually need. As you update your compiler, it'll end up tweaking exactly what that general optimization does based on what they know today.

Because that's the thing about these flags, you'll generally set them once at the beginning of a project. Compiler authors will reevaluate them way more than you will.

Also, a trap I've observed is setting flags based on bad benchmarks. This applies more to the JVM than a C++ compiler, but never the less, a system's current state is somewhat random. 1->2% fluctuations in performance for even the same app is normal. A lot of people won't realize that and ultimately add flags based on those fluctuations.

But further, how code is currently layed out can affect performance. You may see a speed boost not because you tweaked the loop unrolling variable, but rather your tweak may have relocated a hot path to be slightly more cache friendly. A change in the code structure can eliminate that benefit.

201984 40 minutes ago | parent [-]

What's your reason for -O2 over -O3?

cogman10 33 minutes ago | parent | next [-]

Historically, -O3 has been a bit less stable (producing incorrect code) and more experimental (doesn't always make things faster).

Flags from -O3 often flow down into -O2 as they are proven generally beneficial.

That said, I don't think -O3 has the problems it once did.

201984 25 minutes ago | parent [-]

Thanks

wavemode 25 minutes ago | parent | prev [-]

You have to profile for your specific use case. Some programs run slower under O3 because it inlines/unrolls more aggressively, increasing code size (which can be cache-unfriendly).

squater 3 hours ago | parent | prev | next [-]

You can never have too much Godbolt!

alfanick 2 hours ago | parent | prev | next [-]

Is there a PDF somewhere? I'm not really able to follow YT videos.

philipportner an hour ago | parent [-]

There's a link to the AoCO2025 tag for his blog posts in the op.

filosofo_rancio 3 hours ago | parent | prev | next [-]

Thanks for sharing, I've always found optimizing a really interesting field, I will keep a close eye!

ktallett 4 hours ago | parent | prev | next [-]

This is really cool. Congrats on the quality of the work!

NooneAtAll3 an hour ago | parent | prev [-]

I don't understand

where is the problem to be solved?

eapriv 36 minutes ago | parent [-]

The problem is “to add two numbers”. The meta-problem is “to learn how computers work”.