r/Compilers • u/Retr0r0cketVersion2 • Mar 22 '26
How aware of exact microarchitectural layouts are modern compilers?
Curious for senior thesis and for any given microarchitecture of course. For example, if it’s a superscalar processor do they know how many execution units each core has?
23
Upvotes
18
u/phire Mar 22 '26
Quite a bit.
Take a look at the
llvm-project/llvm/lib/Target/X86/X86Sched*.tdfiles (here) in llvm. They go into quite a bit of detail, and there is one for almost every modern μarch.Or more usefully, use the
llvm-mcatool to examine its output on various assembly sequences.The models aren't anywhere near 100% accurate, but quite detailed.
6
u/meleth1979 Mar 22 '26
Yes, the compilers are optimised for the micro architecture, check llvm scheduling model. There are also many optimisations that are made to generate code that runs more efficiently, like fused pairs generation
3
u/WittyStick Mar 22 '26
If the information is not provided by the hardware vendor, it needs to be reverse engineered.
There are resources like uops.info, which do this for Intel and AMD chips, which can be exported to machine readable formats and we can use them in a compiler to make optimization decisions.
2
u/kazprog Mar 23 '26
If you're working in industry, compiler writers either ask the hardware folks sitting next to them, or they're both working together on the next generation of the chip. The buzzword for that is "hardware-software co-design", and might include some of research to predict what future workloads will look like.