------- Comment #2 from wvangulik at xs4all dot nl 2009-04-07 09:51 ------- The problem is it uses R22 as loop counter and as the shift counter. I could not (yet) reproduce the problem in a smaller example.
This could be the same problem as: http://lists.gnu.org/archive/html/avr-gcc-list/2009-03/msg00203.html or http://lists.gnu.org/archive/html/avr-gcc-list/2009-03/msg00158.html ; (insn 16 15 17 main.c:24 (set (reg/v:HI 22 r22 [orig:42 _left ] [42]) ; (ashift:HI (reg/v:HI 22 r22 [orig:42 _left ] [42]) ; (reg:QI 22 r22 [orig:54 _right.2 ] [54]))) 54 {ashlhi3} (expr_list:REG_DEAD (reg:QI 18 r18 [orig:54 _right.2 ] [54]) ; (expr_list:REG_UNUSED (reg:QI 23 r23) ; (nil)))) rjmp 2f ; 16 ashlhi3/1 [length = 6] 1: lsl r22 rol r23 2: dec r22 brpl 1b An other interresting point is the rtl stating reg 23 is unused. Unfortunatly the avr backend can not remove the useless shift. But that is another issue. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39635