Landing: a20f4528f3ab

Project / Subsystem

gcc / tree-optimization

Date

2026-05-08

Author

Philipp Tomsich

Commit

a20f4528f3ab84afc2568ea1e208f33fe59bec66

Source

github

Perf win

Yes

Breaking

No

All attributes

project
gcc
subsystem
tree-optimization
patch_id
commit_hash
a20f4528f3ab84afc2568ea1e208f33fe59bec66
source_type
github
headline
tree-optimization/122569 - recognize CLZ via isolated MSB DeBruijn lookup
tldr
Compiler now recognizes a CLZ idiom using an isolated MSB and DeBruijn lookup for potential performance gains.
author
Philipp Tomsich
outcome
committed
performance_win
true
breaking_change
false
series_id
series_parts
[]
tags
  • optimization
  • tree-optimization
  • intrinsics
discussion_id_link
bugzilla_pr
date
2026-05-08T00:00:00.000Z

GCC can now recognize a count-leading-zeros (CLZ) optimization pattern. This pattern appears after an OR-cascade and uses a value transformation to isolate the most significant bit (MSB) as a power of two, which is then mapped to the bit position using a DeBruijn lookup. The frontend is updated to support this optimization, potentially improving performance for operations involving CLZ where this specific idiom is present.