Landing: 75f572322c01
Project / Subsystem
gcc / match.pd
Date
2026-08-10
Author
Kyrylo Tkachov
Commit
75f572322c011229794476502f52a9ae530107f8
Source
github
Perf win
Yes
Breaking
No
All attributes
- project
- gcc
- subsystem
- match.pd
- patch_id
- —
- commit_hash
- 75f572322c011229794476502f52a9ae530107f8
- source_type
- github
- headline
- match.pd: Optimize power-of-two round-up calculations
- tldr
- Optimizes power-of-two round-up calculations by folding an identity, reducing instruction count on AArch64.
- author
- Kyrylo Tkachov
- outcome
- committed
- performance_win
- true
- breaking_change
- false
- series_id
- —
- series_parts
- []
- tags
-
- • optimization
- • aarch64
- • code generation
- discussion_id_link
- —
- bugzilla_pr
- —
- date
- 2026-08-10T00:00:00.000Z
This commit optimizes power-of-two round-up calculations by applying an algebraic identity that reduces the number of instructions required. The optimization targets expressions of the form ((x - 1) | C) + 1, where C is a power-of-two minus one. The new form, (x + C) & -(C + 1), is more efficient, especially for wrapping arithmetic. This change reduces the instruction count for such operations on scalar and vector integral types, demonstrated by a reduction from three to two instructions on AArch64.