Landing: e548eb628c68
Project / Subsystem
gcc / match
Date
2026-09-11
Author
Andrea Pinski
Commit
e548eb628c689e2836e570aef98b9547aff97a02
Source
github
Perf win
Yes
Breaking
No
All attributes
- project
- gcc
- subsystem
- match
- patch_id
- —
- commit_hash
- e548eb628c689e2836e570aef98b9547aff97a02
- source_type
- github
- headline
- Simplify `x+umax(x,1)` to `umax(x*2, 1)`.
- tldr
- New optimization pattern for `x+umax(x,1)` simplifies code for `std::vector::push_back`.
- author
- Andrea Pinski
- outcome
- committed
- performance_win
- true
- breaking_change
- false
- series_id
- —
- series_parts
- []
- tags
-
- • optimization
- • pattern matching
- • cpp
- discussion_id_link
- —
- bugzilla_pr
- —
- date
- 2026-09-11T00:00:00.000Z
This commit introduces a new optimization pattern that transforms x + umax(x, 1) into umax(x * 2, 1), provided that x * 2 is known not to overflow. This simplification is particularly useful for the std::vector::push_back implementation, as it can trade a post-umax addition for a pre-umax shift, potentially improving code generation. This pattern is seen as a special case of a more general x + minmax(a, b) optimization.