Skip to content
0:00 / 0:00

#compilerexplorer#assembly#optimization

CppCon 2017: Matt Godbolt “What Has My Compiler Done for Me Lately? Unbolting the Compiler's Lid”

CppCon

189K subscribers • 103 videos on Hallway • Conference channel

YouTube
  • Recommended by 10 people: 7 on Hacker News, 1 on Lobsters, 1 in engineering communities and 1 curated list.
  • A classic. People kept recommending it from 2017 to 2021.
  • Presented by Matt Godbolt, creator of Compiler Explorer
  • Linked in the descriptionCppCon/CppCon2017

Intermediate. Assumes working knowledge.

177K views9 years ago10 recommendations

Systems programmingProgramming languagesCompilers and interpretersPerformance and optimizationC++

Matt Godbolt demonstrates how modern compilers optimize C++ code into assembly, using Compiler Explorer to reveal surprising optimizations.

CppCon.org — Presentation Slides, PDFs, Source Code and other presenter materials are available at: github.com/CppCon/CppCon2017 — In 2012, Matt and a colleague were arguing whether it was efficient to use the then-new-fangled range for. During the discussion a bash script was written to quickly compile C++ source and dump the assembly. Five years later and that script has grown into a website relied on by many to quickly see the code their compiler emits, to compare different compilers' code generation and behaviour, to quickly prototype and share code, and investigate the effect of optimization flags. In this talk Matt will not only show you how easy (and fun!) it is to understand the assembly code generated by your compiler, but also how important it can be. He'll explain how he uses Compiler Explorer in his day job programming low-latency trading systems, and show some real-world examples. He'll demystify assembly code and give you the tools to understand and appreciate how hard your compiler works for you. He'll also talk a little about how Compiler Explorer works behind the scenes, how it is maintained and deployed, and share some stories about how it has changed over the years. By the end of this session you'll be itching to take your favourite code snippets and start exploring what your compiler does with them. — Matt Godbolt: DRW, Senior Software Engineer Matt Godbolt is a software engineer with trading firm DRW, and the creator of the Compiler Explorer website. He is passionate about writing efficient code. He has previously worked at on mobile apps at Google, run his own C++ tools company and spent more than a decade making console games. When he's not hacking on Compiler Explorer, Matt enjoys writing emulators for old 8-bit computer hardware. — Videos Filmed & Edited by Bash Films: BashFilms.com Work at Hudson River Trading (HRT): tinyurl.com/safxfctf

Why it's here

10 people recommend this

What people say. Highly recommended for its mind-blowing demonstrations of compiler optimizations and the architecture of Compiler Explorer.

Moments people linked to

drejon Hacker News • Recommends

On “Compiler Explorer”

Matt Godbolt is a great speaker as well. I loved this talk that included a bit about the architecture behind his Compiler Explorer. The rest of his talk is super cool as well. E.g. closed form solutions from O(n) code? Compilers are awesome. link to this video

snailmailmanon Hacker News • Recommends

On “Popcount CPU instruction”

I highly recommend Matt Godbolt's talk "What has my compiler done for me lately?"0 and its follow-up1. Both are great presentations going into details on some of the crazy optimizations compilers will do. As someone who knows very little about the inner workings of compilers my mind was blown when I saw some them. 0 link to this video 1 link

fs111on Lobsters • Recommends

What Has My Compiler Done for Me Lately? Unbolting the Compiler's Lid

u/oilshellin r/ProgrammingLanguages • Recommends

CppCon 2017: Matt Godbolt “What Has My Compiler Done for Me Lately? Unbolting the Compiler's Lid” link to this video
6View on Reddit

programming-talkscurated list on GitHubRecommends

Under “Compilers/Interpreters”

What Has My Compiler Done for Me Lately? Unbolting the Compiler's Lid 01:15:45 by **Matt Godbolt** (2017)

pkayeon Hacker News • Recommends

On “Outperforming LAPACK with C++ metaprogramming”

You should check out this presentation done by Matt Godbolt about compiler internals. He talks about what kind of optimizations are being done by GCC and Clang. Pretty amazing stuff. For example, the compiler will figure out you are trying to write a pop count in high level code and replace it with a single popcount instruction. link to this video

highesttideon Hacker News • Recommends

On “Ask HN: What are some of the best technical talks you've heard?”

What has my compiler done for me lately? - Matt Godbolt link to this video Entertaining talk, not extremely in depth, though.

drejon Hacker News • Recommends

On “C++: Associative map containers with compile-time lookup”

CppCon has super interesting content. That comes from a person who has written maybe two dozen lines of C++ code, mostly just hello world. E.g. this talk by Matt Godbolt or anything by Chadler Carruth. link to this video

fps_dougon Hacker News • Recommends

On “Color Emulation”

But please keep in mind that today's compilers are (most of the time) very smart. Hacker's Delight is somewhat outdated today. There's no need anymore for writing "x << 2" instead of "x * 4". I recommend Matt Godbolt's Talk(s) about compiler cleverness: link to this video (see the 30 minute mark for the multiplication example)

manaskarekaron Hacker News • Recommends

On “I translated a simple C program to x86_64 and it was slower”

Tangent, but this reminds me of this great talk by Matt Godbolt from CppCon 2017: “What Has My Compiler Done for Me Lately? Unbolting the Compiler's Lid” link to this video . And the follow up link .

s3cur3on Hacker News • Recommends

On “Performance comparison: counting words in Python, Go, C++, C, Awk, Forth, Rust”

Link to the (great) CppCon talk: link to this video The one thing I would say is: as you dig more into C++ perf, you can develop an intuition for the kinds of things the compiler can and can't optimize. For instance, the C++ example from the article uses `std::unordered_map`, which is just an absolute mess from a cache locality perspective—the best compilers today (or of the foreseeable future) can't do a thing to fix that. Improving the programmer's choice of data structure is just not on the radar. :(

u/skeetoin r/C_Programming • Mentions

On “Why is there no C conference?”

Every year you can think of a subset of CppCon as being like a C conference. There are a bunch of presentations that are entirely or mostly relevant to C, and not just in a broader sense of being relevant to *any* language. I plucked out a bunch from CppCon 2017 for you. These are *roughly* ordered from best to worst: * [Matt Godbolt “What Has My Compiler Done for Me Lately? Unbolting the Compiler's Lid”] * Chandler Carruth “Going Nowhere Faster” * James McNellis “Everything You Ever Wanted to Know about DLLs” * John Regehr “Undefined Behavior in 2017 (part 1 of 2)” * John Regehr “Undefined Behavior in 2017 (part 2 of 2)” * Piotr Padlewski “Undefined Behaviour is awesome!” * [Tob…

u/suprjamiin r/C_Programming • Mentions

On “Loop Optimizations: taking matters into your hands”

Yeah, I assume the author is trying to give advice in good faith, but they don't realise they have an outdated or inaccurate idea of what compilers and CPUs can do. GCC has made some amazing optimisations even in the last few years. Even statements which are accurate today could be outdated tomorrow. (I'm halfway through writing a short post series about this). As Matt Godbolt said (and demonstrated) in his great CppCon 17 talk, the world is no longer like Michael Abrash's 1990s assembly books. link to this video

u/d1722825in r/C_Programming • Mentions

On “How can I let the compiler know that a for loop will be executed at least once, so it can optimize?”

Compilers do that already in higher optimization leves. # ------------- Edit: It seems that you are just learning C or programming in general. If this is the case, really SHOULD NOT think about this level of optimization of your program. You should work mainly on writing good code that does the right thing, it is understandable and maintainable. This level of optimization will probably only be interesting if you are writing code for some high-frequency-trading, scientific computing on machines with thousands of CPU cores, or eg. a low level game engine. Please watch this talk by Matt Godbolt (the author of Compiler Explorer). It will show some light on the whole topic and make sure th…

u/oilshellin r/ProgrammingLanguages • Mentions

On “Monthly "What are you working on? How is it coming along?" thread - Happy New Year! - January '18”

…sive! I'm surprised you are already in the position to make a playground -- nice progress. I stumbled across your railroad diagrams too: http://web3d.jondgoodwin.com/cone/diagram.xhtml I didn't know about that tool, very cool! ---- BTW the popular C++ tool which runs a ton of compilers on the web is written in node.js: https://godbolt.org/ link to this video node.js is fairly unique for this, because it has good web libraries and an async / event-driven process abstraction. Most languages like Python and Ruby have a fairly limited synchronous process API. For a quick and dirty demo, I think Python or Ruby is fine. Each web server thread can wait for one process. But if it were under load,…

foxrob92on Hacker News • Mentions

On “Compiler Explorer”

Doesn't look like it works any more. In any case, Matt Godbolt has spoken a bit about the architecture of Compiler Explorer. Seems like he's given some thought to security. link to this video link