Landing: 59c8c4bbac46
Project / Subsystem
gcc / tree-optimization
Date
2026-09-22
Author
Naveen
Commit
59c8c4bbac46570ac36782172ed28569affe42c4
Source
github
Perf win
No
Breaking
No
All attributes
- project
- gcc
- subsystem
- tree-optimization
- patch_id
- —
- commit_hash
- 59c8c4bbac46570ac36782172ed28569affe42c4
- source_type
- github
- headline
- tree-optimization: Fold abs(x) comparisons with x
- tldr
- GCC can now fold comparisons involving abs(x) and x, simplifying expressions and improving optimization.
- author
- Naveen
- outcome
- committed
- performance_win
- false
- breaking_change
- false
- series_id
- —
- series_parts
- []
- tags
-
- • tree-optimization
- • abs
- • comparison
- • optimization
- discussion_id_link
- —
- bugzilla_pr
- —
- date
- 2026-09-22T00:00:00.000Z
This optimization pass folds comparisons involving the absolute value of a variable x and x itself. It handles both undefined-overflow and wrapping-overflow semantics, simplifying such comparisons to constants or sign tests. This transformation is applied even when x is unsigned after conversion. The new patterns reduce code complexity and enable further optimizations by making the relationship between abs(x) and x explicit.