LLVM Clang 12 Compiler Is Performing Very Well For AMD Ryzen 9 5950X / Zen 3
Earlier this week I posted some benchmarks looking at the compiler performance of GCC 11 vs. LLVM Clang 12 on the Intel Core i9 11900K "Rocket Lake" processor while in this article the same tests and same software are being carried out on an AMD Ryzen 9 5950X "Zen 3" desktop. With these AMD Linux tests the Clang 12 compiler not only yielded the fastest binaries at -O2 but carried through in the more optimized configurations as well.
This article is looking at the Ryzen 9 5950X compiler performance with the recently released GCC 11 and LLVM Clang 12 compilers. The same benchmarks and same software stack as used in the Rocket Lake comparison were done for this Zen 3 benchmarking of these fresh open-source compilers. That includes testing both compilers with the "-O2" optimization level, "-O3 -march=native" for the more optimized configuration, and then "-O3 -march=native -flto" for also flipping on link-time optimizations (LTO).
The AMD Ryzen 9 5950X with ASUS CROSSHAIR VIII HERO system was tested with Fedora 34 on Linux 5.11 just as with the Rocket Lake tests while evaluating GCC 11.1.1 and LLVM Clang 12.0 with their release builds from the F34 repository.
When taking the geometric mean of all the Rocket Lake compiler tests, Clang 12 was 4% faster than GCC 11 at the -O2 optimization level while at "-O3 -march=native" is where GCC 11 came out slightly ahead.If skipping ahead and showing the AMD Ryzen 5950X geometric mean for the same set of benchmarks... On the AMD Zen 3 side, at -O2 the Clang compiler was 3.5% faster. But where it differs from the Intel Rocket Lake results is that at "-O3 -march=native" the Clang compiler still squeaked past GCC 11, including when making use of Link Time Optimizations. In the most optimized configuration tested, Clang 12 was still about 4% faster than GCC 11 on this Zen 3 system, unlike GCC leading on the Intel side.
Making this even more interesting is that in the final days of the GCC 11 cycle is when the AMD Zen 3 optimizations were landing. While Clang 12 has initial Znver3 support, the Zen 3 scheduler model was only added to LLVM/Clang earlier this month as post-12.0 material. So it's possible for the next Clang release there might even be better AMD Ryzen 5000 / EPYC 7003 performance when making use of the CPU-specific tuning.
Anyhow, let's get on to looking at some of the most interesting individual benchmark results for this current compiler benchmarking on the Ryzen 9 5950X.