Merged today to the LLVM/Clang compiler codebase are some long overdue adjustments to the AMD Zen 4 “znver4” CPU model for more accurately assessing various latency timings and micro-ops. These values were initially copied over from the Zen 3 (znver3) target but never adjusted properly for Zen 4 until now when an independent contributor took to sorting it out.
Open-source developer “NexusXe” took to sorting out some Znver4 model deficiencies that had been copied over from Znver3 but never updated to properly reflect the architectural/hardware differences with Zen 4. Three weeks ago the pull request was opened while today the code was merged to LLVM Git.
“This PR fixes a handful of latency and uop changes between Znver3 and Znver4 that were otherwise copied from Znver3.
Latency and uop values listed that matched Zen3 on uops.info were updated to those for Zen4.
Includes: BSF/BSR, DIV, TZCNT, CLMUL, PCMPISTRM, VALIGN, VPERM”
These latency numbers and other adjustments were gleaned off public information from uops.info. It’s great seeing the Zen 4 CPU model being improved for helping with -march=znver4 compiler performance but unfortunate it’s taken so long and that AMD didn’t have their support primed from the start.
The merge to LLVM Git for LLVM 22 will in turn be out as stable in March… At that point over three years since Zen 4 first launched. Meanwhile AMD’s in-house AOCC downstream of LLVM/Clang hasn’t seen a new release since AOCC 5.0 last November. There are also improvements still due to Znver5 for the likes of GCC and LLVM/Clang. This area of open-source compiler optimizations is one of the areas where AMD can still make better and more timely contributions. Over on the Intel side, they have already begun their Nova Lake compiler work following Diamond Rapids, Panther Lake, and Clearwater Forest support being upstream for a while already. Meanwhile there isn’t yet any public AMD Zen 6 “znver6” compiler patches for GCC or Clang but hopefully they will come soon to make the GCC 16 and Clang 22 releases early next year.