GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
match-sat-alu.pd Performance Win

match-sat-alu.pd: Recognize signed saturating truncation after a shift

GCC now optimizes signed saturating truncation that follows an arithmetic right shift, simplifying code.

GCC’s match-sat-alu.pd pattern matcher can now recognize and optimize signed saturating truncation that occurs after an arithmetic right shift. This optimization allows the saturation value to use the original input while the shift operates on the already shifted value. This can simplify complex code sequences, such as an AArch64 example that reduces to a single SQSHRN instruction.

In Details

The match-sat-alu.pd pattern matcher has gained the ability to recognize signed saturating truncation (.SAT_TRUNC) following an arithmetic right shift. This pattern is applicable when the input sign is preserved by the shift, allowing the saturation logic to use the original input value while the shift operates on it. The commit requires the data shift to be a constant less than the input precision and the range type to be at least as wide as the shifted value and output type. This enables a significant simplification for a specific sequence, demonstrated by an AArch64 example reducing to…

For Context
signed saturating truncation
A conversion to a narrower signed integer type where the result is clamped to the minimum or maximum representable value of the target type if the original value falls outside that range. This prevents overflow by capping the result.
arithmetic right shift
A bitwise operation that shifts the bits of a number to the right. For signed numbers, the sign bit is propagated to preserve the sign of the number.
pattern matcher
A component within a compiler that identifies specific sequences of intermediate representation (IR) operations that can be replaced by more efficient instructions or simpler IR forms. This is crucial for optimization.
Filed Under: optimizationgccaarch64