Landing: 60379a459b0e
Project / Subsystem
gcc / gcc/match.pd
Date
2026-07-31
Author
Kyrylo Tkachov
Commit
60379a459b0eab9fee4ad4681cb3a1e7f3092307
Source
github
Perf win
Yes
Breaking
No
All attributes
- project
- gcc
- subsystem
- gcc/match.pd
- patch_id
- —
- commit_hash
- 60379a459b0eab9fee4ad4681cb3a1e7f3092307
- source_type
- github
- headline
- Drop clamp expressions where bounds cross
- tldr
- GCC now removes redundant clamping operations where the bounds are logically inverted.
- author
- Kyrylo Tkachov
- outcome
- committed
- performance_win
- true
- breaking_change
- false
- series_id
- —
- series_parts
- []
- tags
-
- • optimization
- • integer
- • inlining
- discussion_id_link
- —
- bugzilla_pr
- —
- date
- 2026-07-31T00:00:00.000Z
GCC’s pattern matching system can now eliminate certain redundant ‘clamp’ expressions. Specifically, expressions like MIN(MAX(X, Y + CST), Y) where CST is positive, or its dual MAX(MIN(X, Y + CST), Y) with a negative CST, are simplified away. These patterns arise after inlining when a clamp’s bounds are already satisfied by prior operations, making the clamp itself unnecessary and reducible to a simple assignment of one of the bounds.