Landing: 610f1166538a
Project / Subsystem
gcc / tree-optimization
Date
2026-07-28
Author
Andrea Pinski
Commit
610f1166538ad2e637c913be78b074100270cc5c
Source
github
Perf win
No
Breaking
No
All attributes
- project
- gcc
- subsystem
- tree-optimization
- patch_id
- —
- commit_hash
- 610f1166538ad2e637c913be78b074100270cc5c
- source_type
- github
- headline
- match: Fix signed integer overflow in pattern for `cmp + (-cmp ^ x)`
- tldr
- Corrects a GCC pattern that introduced unintended signed integer overflow with INT_MIN.
- author
- Andrea Pinski
- outcome
- committed
- performance_win
- false
- breaking_change
- false
- series_id
- —
- series_parts
- []
- tags
-
- • optimization
- • bugfix
- • integer overflow
- • pattern matching
- discussion_id_link
- —
- bugzilla_pr
- —
- date
- 2026-07-28T00:00:00.000Z
A recent addition to GCC’s pattern matching system inadvertently introduced signed integer overflow for specific inputs, particularly when dealing with INT_MIN. The pattern cmp + (-cmp ^ x) was incorrectly translated, causing overflow when x was INT_MIN and cmp was 0. This commit fixes the issue by using an unsigned type for the negation, preventing the overflow.