Landing: 1320bc377dab
Project / Subsystem
gcc / gcc/match-sat-alu.pd
Date
2026-07-30
Author
Kyrylo Tkachov
Commit
1320bc377dab63d1c9a83662c49d01f3a166332c
Source
github
Perf win
Yes
Breaking
No
All attributes
- project
- gcc
- subsystem
- gcc/match-sat-alu.pd
- patch_id
- —
- commit_hash
- 1320bc377dab63d1c9a83662c49d01f3a166332c
- source_type
- github
- headline
- match-sat-alu.pd: Recognize X - MIN(X, Y) as saturating subtraction
- tldr
- Enables recognizing 'X - MIN(X, Y)' as an unsigned saturating subtraction for better code generation.
- author
- Kyrylo Tkachov
- outcome
- committed
- performance_win
- true
- breaking_change
- false
- series_id
- —
- series_parts
- []
- tags
-
- • gcc
- • optimization
- • aarch64
- • pattern matching
- discussion_id_link
- —
- bugzilla_pr
- —
- date
- 2026-07-30T00:00:00.000Z
This commit introduces recognition for the pattern ‘X - MIN(X, Y)’ as an unsigned saturating subtraction in GCC. This form, equivalent to X - (X < Y ? X : Y), can be efficiently translated into a single saturating subtraction instruction on some architectures. The change requires that the MIN operand has only one use to ensure its removal after replacement and updates related optimizers to correctly report replacements and prevent subsequent transformations. This leads to improved code for vector forms, replacing multiple instructions with a single UQSUB on AArch64.