Landing: a66820ce3f5b
Project / Subsystem
gcc / tree-optimization
Date
2026-04-09
Author
Philipp Tomsich
Commit
a66820ce3f5b298759042b6543a056b490370310
Source
github
Perf win
Yes
Breaking
No
All attributes
- project
- gcc
- subsystem
- tree-optimization
- patch_id
- —
- commit_hash
- a66820ce3f5b298759042b6543a056b490370310
- source_type
- github
- headline
- Tree-optimization: Avoid Shift-by-64 Undefined Behavior
- tldr
- The DeBruijn CLZ table validator now avoids undefined behavior by special-casing the MSB bit, resolving a long-standing issue.
- author
- Philipp Tomsich
- outcome
- committed
- performance_win
- true
- breaking_change
- false
- series_id
- —
- series_parts
- []
- tags
-
- • tree-optimization
- • undefined behavior
- • count leading zeros
- • DeBruijn
- discussion_id_link
- —
- bugzilla_pr
- —
- date
- 2026-04-09T00:00:00.000Z
The DeBruijn CLZ (count leading zeros) table validator in GCC’s tree-optimization pass had an issue where it would perform a shift by the number of bits in a HOST_WIDE_INT, resulting in undefined behavior. This affected 64-bit inputs, causing the validator to reject well-formed CLZ tables. The fix special-cases this scenario, ensuring correct validation and enabling optimizations relying on DeBruijn CLZ tables.