Landing: b627bfa76649

Project / Subsystem

gcc / match-sat-alu.pd

Date

2026-08-23

Author

Kyrylo Tkachov

Commit

b627bfa76649bb65ccab8d9aad9c1b1f1d45cdde

Source

github

Perf win

Yes

Breaking

No

All attributes

project
gcc
subsystem
match-sat-alu.pd
patch_id
—
commit_hash
b627bfa76649bb65ccab8d9aad9c1b1f1d45cdde
source_type
github
headline
match-sat-alu.pd: Recognize complement masks for unsigned saturating truncation
tldr
GCC's pattern matcher now recognizes an alternative way to express unsigned saturating truncation using bitwise complement.
author
Kyrylo Tkachov
outcome
committed
performance_win
true
breaking_change
false
series_id
—
series_parts
[]
tags
  • • optimization
  • • gcc
  • • aarch64
discussion_id_link
—
bugzilla_pr
—
date
2026-08-23T00:00:00.000Z

The GCC pattern matcher in match-sat-alu.pd has been updated to recognize unsigned saturating truncation when the sign mask is formed using a bitwise complement (~X) instead of negation (-X). This optimization avoids potential issues with negating the minimum signed value and can lead to more efficient code generation, as demonstrated by an AArch64 example showing a reduction from multiple instructions to a single smax and uqxtn sequence.