Landing: 8d004ef91c4f
Project / Subsystem
gcc / match
Date
2026-07-28
Author
Andrea Pinski
Commit
8d004ef91c4f7c315519975ffaec78d28d4a21ff
Source
github
Perf win
Yes
Breaking
No
All attributes
- project
- gcc
- subsystem
- match
- patch_id
- —
- commit_hash
- 8d004ef91c4f7c315519975ffaec78d28d4a21ff
- source_type
- github
- headline
- Remove casts for `(int)-(unsigned)a`
- tldr
- Optimizes negation of unsigned integers cast to signed types by removing redundant casts.
- author
- Andrea Pinski
- outcome
- committed
- performance_win
- true
- breaking_change
- false
- series_id
- —
- series_parts
- []
- tags
-
- • optimization
- • type conversion
- • pattern matching
- discussion_id_link
- —
- bugzilla_pr
- —
- date
- 2026-07-28T00:00:00.000Z
This commit optimizes the negation of unsigned integers cast to signed types, specifically targeting expressions like (int)-(unsigned)a. It introduces checks to remove redundant casts when signed integer overflow occurs, aligning with the behavior of -fwrapv. The optimization is achieved by refining pattern matching rules to recognize and simplify these expressions, including handling cases where the result of the negation might be INT_MIN. New test cases are provided.