Landing: 1c8ca0108746
Project / Subsystem
gcc / match
Date
2026-06-17
Author
Eikansh Gupta
Commit
1c8ca0108746d3a7452134f9d1c2e5d89857fed7
Source
github
Perf win
No
Breaking
No
All attributes
- project
- gcc
- subsystem
- match
- patch_id
- —
- commit_hash
- 1c8ca0108746d3a7452134f9d1c2e5d89857fed7
- source_type
- github
- headline
- MATCH: fold signbit comparison and conditional negate to copysign [PR109843]
- tldr
- MATCH rule simplifies signbit comparisons and conditional negations into copysign operations.
- author
- Eikansh Gupta
- outcome
- committed
- performance_win
- false
- breaking_change
- false
- series_id
- —
- series_parts
- []
- tags
-
- • optimization
- • MATCH
- • copysign
- discussion_id_link
- —
- bugzilla_pr
- —
- date
- 2026-06-17T00:00:00.000Z
A new rule has been added to the GCC MATCH optimization patterns to recognize and simplify a common code sequence involving sign bit comparisons and conditional negations. The pattern (signbit (x) cmp1 0) cmp (signbit (y) cmp2 0) ? y : -y is now folded into a copysign(y, +-x) operation. This transformation preserves the magnitude of y while taking its sign from x (or -x), and can be emitted as IFN_COPYSIGN on supporting targets, leading to more efficient code for operations like copysign and potentially improving performance.