*I noticed something interesting while running a GCC vs Clang benchmark.
*
Same code. Same machine.
Both loops are scalar (no vectorization).
Yetโฆ GCC consistently used fewer CPU cycles.
At first, this doesnโt make sense.
If both:
execute roughly the same instructions
are not vectorised
Why is there a performance gap?
๐ The Missing Piece: Itโs Not Just Instructions
Most people focus on:
instruction count
vectorization
But in this case, thatโs not the full story.
What actually matters more is:
- how address computations are structured
- how instructions are scheduled
- how well latency is hidden
Here is the data
โ๏ธ AGU Pressure (Address Generation Units)
On x86 CPUs, memory instructions rely on AGUs (Address Generation Units).
Complex addressing patterns like:
base + index * scale + offset
๐ increase AGU pressure
Whereas simpler patterns like:
pointer++
๐ are cheaper and easier for the CPU to execute efficiently
๐งช What I Observed
GCC:
Generates simpler addressing patterns
Reduces AGU contention
Keeps execution more consistent
Clang:
Shows higher AGU pressure
More stalls
Less efficient scheduling (in this case)
โก Key Takeaway
Itโs not just about what instructions exist.
Itโs about:
How efficiently the compiler feeds the CPU pipeline
Same instruction count โ same performance.
๐ Why This Matters
In tight loops:
AGU pressure
addressing patterns
instruction scheduling
๐ can matter as much as (or more than) vectorization
๐ Want to Dive Deeper?
๐ Full benchmark + assembly breakdown:
๐ Complete analysis article:
๐ฌ Discussion
Have you seen cases where:
similar assembly
same instruction count
๐ still results in very different performance?
Would love to hear your observations.

Top comments (1)
AI GCC