GCC Git Adjusts Unaligned Load/Store Costs For AMD Zen 4 & Zen 5

Written by Michael Larabel in GNU on 16 July 2024 at 06:22 AM EDT. 10 Comments
GNU
Stemming from a recent investigation into a GCC compiler regression on Zen 4, it was discovered that the unaligned load/store costs for the Zen 4 and Zen 5 targets were inaccurate and have now been tweaked within GCC Git.

GCC compiler expert Richard Biener at SUSE reported the original Zen 4 regression and went on to analyze and fix-up the issue. In updating the unaligned load/store costs for the "Znver4" compiler target he explained:
"Fixup unaligned load/store cost for znver4

Currently unaligned YMM and ZMM load and store costs are cheaper than aligned which causes the vectorizer to purposely mis-align accesses by adding an alignment prologue. It looks like the unaligned costs were simply left untouched from znver3 where they equate the aligned costs when tweaking aligned costs for znver4. The following makes the unaligned costs equal to the aligned costs.

This avoids the miscompile seen in PR115843 but it's of course not a real fix for the issue uncovered there. But it makes it qualify as a regression fix."

It's not the first time we've seen AMD Zen targets a bit hairy as a result of starting off by copying over from prior Zen revisions but the cost tables not always being updated accurately.

AMD Ryzen Zen 4 CPUs


And then similarly the Zen 5 (znver5) target was originally copied over too and thus it also needed updating:
"Currently unaligned YMM and ZMM load and store costs are cheaper than aligned which causes the vectorizer to purposely mis-align accesses by adding an alignment prologue. It looks like the unaligned costs were simply copied from the bogus znver4 costs. The following makes the unaligned costs equal to the aligned costs like in the fixed znver4 version."

At least as being treated as a "regression fix" these AMD Zen tuning patches should be picked up in time for the upcoming GCC 14.2 point release.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week