tl; The dr compiler was designed to use a more portable, efficient and generic solution here.
The SUBI set contains the CPU tags C (carry) and H (half-carry) for use with subsequent ones (in the 8-bit AVR BTW there is no ADDI , therefore, to add the immediate value of x we subtract -x from it), while INC does not. Since both SUBI and INC are 2 bytes long and run for 1 clock, you lose nothing using SUBI - OTOH, if you use an 8-bit counter, you can easily find ( BRCC / BRCS ), and if you have there will be a 16 or 32 bit counter, this will allow you to increase it in a very simple way - only with INC , 0x00FF will be increased to 0x0000 , so you will need to check if the low byte 0xFF before INC ing. OTOH, with SUBI you are just SUBI -1 low byte, and then ADC 0 for the next bytes, ensuring that all potential carry bits are accounted for.
Further reading:
https://lists.gnu.org/archive/html/avr-gcc-list/2008-11/msg00029.html
http://avr-gcc-list.nongnu.narkive.com/SMMzdBkW/foo-subi-vs-inc
source share