Landing: 9c40f8de1890
Project / Subsystem
gcc / gcc/match.pd
Date
2026-05-01
Author
Daniel Henrique Barboza
Commit
9c40f8de18908bd0e09dafd5e21895d285044e11
Source
github
Perf win
Yes
Breaking
No
All attributes
- project
- gcc
- subsystem
- gcc/match.pd
- patch_id
- —
- commit_hash
- 9c40f8de18908bd0e09dafd5e21895d285044e11
- source_type
- github
- headline
- Match.pd: Implement `(A>>C) != (B>>C) -> (A^B) >= (1<<C)` transformation.
- tldr
- The compiler now optimizes `(A>>C) != (B>>C)` into `(A^B) >= (1<<C)`, potentially improving performance.
- author
- Daniel Henrique Barboza
- outcome
- committed
- performance_win
- true
- breaking_change
- false
- series_id
- —
- series_parts
- []
- tags
-
- • optimization
- • bit manipulation
- discussion_id_link
- —
- bugzilla_pr
- —
- date
- 2026-05-01T00:00:00.000Z
A new pattern is added to match.pd that transforms (A>>C) != (B>>C) into (A^B) >= (1<<C) and its counterpart (A>>C) == (B>>C) -> (A^B) < (1<<C). This optimization can improve performance by replacing right bit shifts and comparisons with a bitwise XOR and a comparison. Checks ensure that the shift amount is not negative and does not exceed the type size.