Landing: 771f488a90f7
Project / Subsystem
gcc / gcc/match.pd
Date
2026-09-13
Author
Dominic P
Commit
771f488a90f748613940a62de40b57d1131b2fcd
Source
github
Perf win
Yes
Breaking
No
All attributes
- project
- gcc
- subsystem
- gcc/match.pd
- patch_id
- —
- commit_hash
- 771f488a90f748613940a62de40b57d1131b2fcd
- source_type
- github
- headline
- Fold A - MIN (B, C) to A + MAX (-B, -C) in match.pd.
- tldr
- GCC's pattern matching now optimizes subtraction with min/max, improving code generation.
- author
- Dominic P
- outcome
- committed
- performance_win
- true
- breaking_change
- false
- series_id
- gcc:match.pd: fold a - min (b, c) to a + max (-b, -c)
- series_parts
- []
- tags
-
- • optimization
- • gcc
- discussion_id_link
- —
- bugzilla_pr
- —
- date
- 2026-09-13T00:00:00.000Z
This commit introduces new patterns to GCC’s match.pd that optimize expressions of the form A - MIN (B, C) and A - MAX (B, C) into additions with negated max/min respectively. This transformation, A - MIN(B, C) -> A + MAX(-B, -C), requires that B and C are negatable and accounts for potential overflow in wrapping types, leading to more efficient code generation.