Linux Kernel & OS

LLVM/Clang fixes optimization regression for AMD Bulldozer architectures

Key Takeaway

A fix in LLVM/Clang prevents the compiler from generating inefficient code for AMD Bulldozer CPUs by restricting vectorization to 128-bit widths.

Summary

Developers have addressed a long-standing optimization issue in the LLVM/Clang compiler codebase specifically affecting AMD Bulldozer-era processors. A bug report identified that using the -march=bdver2 tuning flag resulted in code that was significantly slower than generic x86_64 instructions and performed much worse than equivalent GCC-compiled code.

The fix, merged into the LLVM Git repository, corrects how the compiler handles vectorization for these older architectures. By adjusting the default vectorization behavior, the compiler will now produce more efficient machine code for users targeting Bulldozer through version 4 processors.

Technical details of the vectorization fix

  • Vector Width Adjustment: The compiler now defaults to 128-bit vector widths for Bulldozer 1 through Bulldozer version 4 processors to avoid performance penalties.
  • Performance Regression Fix: The update resolves a bug where -march=bdver2 tuning produced code approximately three times slower than generic x86_64 targets.
  • Compiler Parity: The fix addresses a discrepancy where GCC was previously providing superior performance for these specific AMD architectures compared to LLVM/Clang.
  • Multi-threaded Impact: By optimizing vectorization preferences, the change specifically improves multi-threaded execution throughput on affected hardware.

Why it matters

This update provides a significant performance boost for users maintaining legacy AMD hardware that relies on LLVM-based toolchains. It ensures that specialized architecture tuning via Clang yields the expected performance benefits rather than causing regressions.

Original reference: www.phoronix.com →