------- Comment #3 from wvangulik at xs4all dot nl 2009-04-07 13:26 ------- (In reply to comment #2) > 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 is my minimal test case: static uint16_t safe_lshift_func_uint16_t_u_u(uint16_t _left, unsigned int _right) { return _left << _right; } char func_7 (uint8_t p_8) { if(safe_lshift_func_uint16_t_u_u (p_8, p_8)) { return 0; } return 1; } Not using the function but shifting it directly solves the problem in this case. It seems to me this problem is triggered when the function is inlined. Note that this also fails for 4.1.2, 4.2.2, 4.3.0 and 4.3.2. (WinAvr20070525, 20071221, 20080610, 20081205) > 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. > -- wvangulik at xs4all dot nl changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |wvangulik at xs4all dot nl http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39635