Landing: c59bee6acb24
Project / Subsystem
gcc / tree-optimization
Date
2026-08-10
Author
Tudor-Stefan Magirescu
Commit
c59bee6acb24a0d580f4c98a14e879452096220e
Source
github
Perf win
Yes
Breaking
No
All attributes
- project
- gcc
- subsystem
- tree-optimization
- patch_id
- —
- commit_hash
- c59bee6acb24a0d580f4c98a14e879452096220e
- source_type
- github
- headline
- tree-optimization: Simplify ((X CMP1 Y) - (X CMP2 Y)) REL 0
- tldr
- Adds a new optimization pattern to simplify differences of comparisons into a single comparison.
- author
- Tudor-Stefan Magirescu
- outcome
- committed
- performance_win
- true
- breaking_change
- false
- series_id
- —
- series_parts
- []
- tags
-
- • optimization
- • tree-optimization
- discussion_id_link
- —
- bugzilla_pr
- —
- date
- 2026-08-10T00:00:00.000Z
This commit introduces a new optimization pattern in match.pd that simplifies expressions of the form ((X CMP1 Y) - (X CMP2 Y)) REL 0 into a single comparison. This pattern specifically targets differences of two comparisons involving the same operands, where the comparison operators are opposites (e.g., gt/lt or ge/le). This enables folding of sign-of-difference expressions into a more efficient comparison, improving generated code.