Landing: 2ed77dddba2e

Project / Subsystem

gcc / gcc/match-sat-alu.pd

Date

2026-07-30

Author

Kyrylo Tkachov

Commit

2ed77dddba2e7f2d4e45ee8606e9b22acb6fb1f3

Source

github

Perf win

Yes

Breaking

No

All attributes

project
gcc
subsystem
gcc/match-sat-alu.pd
patch_id
—
commit_hash
2ed77dddba2e7f2d4e45ee8606e9b22acb6fb1f3
source_type
github
headline
match-sat-alu.pd: Recognize more unsigned saturating subtraction forms
tldr
Improves recognition of unsigned saturating subtractions with swapped operands or reversed conditional arms.
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 enhances the recognition of unsigned saturating subtraction operations in GCC. It now correctly identifies forms where the comparison operands or conditional arms are reversed, such as ‘B < A ? A - B : 0’ or ‘A < B ? 0 : A - B’. This allows the compiler to apply more efficient instructions, like AArch64’s UQSUB, replacing sequences of comparisons, subtractions, and conditional selects, leading to better code generation.