Landing: f84dfd830596
Project / Subsystem
gcc / avr
Date
2026-07-03
Author
Georg-Johann Lay
Commit
f84dfd8305963f124c624570bb6eb0c84149f67a
Source
github
Perf win
Yes
Breaking
No
All attributes
- project
- gcc
- subsystem
- avr
- patch_id
- —
- commit_hash
- f84dfd8305963f124c624570bb6eb0c84149f67a
- source_type
- github
- headline
- AVR: Adding +/-1 to a lower reg doesn't need a scratch.
- tldr
- AVR target code generation for adding/subtracting 1 is optimized to avoid using a scratch register.
- author
- Georg-Johann Lay
- outcome
- committed
- performance_win
- true
- breaking_change
- false
- series_id
- —
- series_parts
- []
- tags
-
- • avr
- • code-generation
- • optimization
- • register-pressure
- discussion_id_link
- —
- bugzilla_pr
- —
- date
- 2026-07-03T00:00:00.000Z
The GCC AVR backend has been optimized to eliminate the need for a scratch register when adding or subtracting 1 from lower-numbered registers. Previously, such operations required a temporary register, increasing register pressure. The new implementation uses sequences of sec (set carry flag) with adc (add with carry) or sbc (subtract with carry) instructions, which achieve the +/-1 operation without spilling to a scratch register, thus reducing register pressure while maintaining code size.