Landing: acd94fdfa20b
Project / Subsystem
gcc / match.pd
Date
2026-07-31
Author
Jakub Jelinek
Commit
acd94fdfa20bf1195061d57a57e85cdd6beaa571
Source
github
Perf win
No
Breaking
No
All attributes
- project
- gcc
- subsystem
- match.pd
- patch_id
- —
- commit_hash
- acd94fdfa20bf1195061d57a57e85cdd6beaa571
- source_type
- github
- headline
- Fix narrow shift count types in shift-compare patterns
- tldr
- Corrected patterns in `match.pd` to handle narrow shift count types accurately, preventing miscompilation of shifts combined with comparisons.
- author
- Jakub Jelinek
- outcome
- committed
- performance_win
- false
- breaking_change
- false
- series_id
- —
- series_parts
- []
- tags
-
- • optimization
- • compiler internals
- • bit-integers
- discussion_id_link
- —
- bugzilla_pr
- —
- date
- 2026-07-31T00:00:00.000Z
This commit addresses two issues in match.pd where shift operations combined with comparisons were miscompiled due to narrow shift count types. Specifically, when the shift count type (e.g., unsigned _BitInt(4)) could not represent the comparison value, the compiler incorrectly simplified the comparison. The fix ensures that such cases are correctly handled, either by simplifying to a comparison against NE_EXPR or by not simplifying if the necessary logarithmic value doesn’t fit the type.