Landing: edb9556068ae
Project / Subsystem
gcc / match
Date
2026-09-12
Author
Andrea Pinski
Commit
edb9556068ae47e1a3cbad69249424ab7cce5b7c
Source
github
Perf win
Yes
Breaking
No
All attributes
- project
- gcc
- subsystem
- match
- patch_id
- —
- commit_hash
- edb9556068ae47e1a3cbad69249424ab7cce5b7c
- source_type
- github
- headline
- Optimize `minmax (a - c, b) + c` to `minmax (a, b + c)`.
- tldr
- New optimization pattern simplifies `minmax (a - c, b) + c` expressions.
- author
- Andrea Pinski
- outcome
- committed
- performance_win
- true
- breaking_change
- false
- series_id
- —
- series_parts
- []
- tags
-
- • optimization
- • pattern matching
- • cpp
- discussion_id_link
- github:gcc-mirror/gcc#127356
- bugzilla_pr
- —
- date
- 2026-09-12T00:00:00.000Z
A new optimization pattern minmax (a - c, b) + c -> minmax (a, b + c) has been added to GCC’s pattern matcher. This transformation is applied when the expression b + c is known not to overflow. This specific optimization was observed to occur in std::vector::push_back and helps in simplifying code by trading a subtraction and addition for a single addition. The current implementation is limited to unsigned types due to overflow checking limitations.