GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
AVR Performance Win

AVR: Support saturating fixed-point shifts

Adds hardware support for saturating fixed-point shifts on AVR microcontrollers.

This patch introduces support for saturating shift left operations on fixed-point types for the AVR microcontroller architecture. It adds new instruction patterns to the AVR backend and includes corresponding support in libgcc and new test cases. This enables efficient implementation of saturation arithmetic, which is crucial for DSP and signal processing applications.

In Details

This commit extends the AVR backend (avr-fixed.md) to support saturating arithmetic left shifts (sat_ashl) for all fixed-point modes, excluding the Reduced Core where 64-bit shifts are unavailable. New mode iterators (ALL12QA) and instruction patterns are added. libgcc is updated to provide implementations for these shifts, and new test cases (sat-shift-s.c, sat-shift-u.c) are introduced in the testsuite. This aims to leverage potential hardware acceleration for these operations.

For Context
Saturating shift
A shift operation where if the result of the shift exceeds the maximum representable value for the data type, it is clamped to that maximum value (saturation). Similarly, if it underflows, it is clamped to the minimum.
Fixed-point arithmetic
A method of representing real numbers using integers, where the position of the decimal point is fixed and implicitly known. It's often used in embedded systems for performance.
AVR
A family of microcontrollers developed by Atmel (now Microchip Technology). GCC has a specific backend to generate code for these processors.
libgcc
The GCC runtime library, which provides essential functions for C and C++ programs, such as arithmetic on fixed-point types, when these operations cannot be directly emitted as machine instructions.
Filed Under: AVRfixed-pointDSPoptimization