http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37895
Georg-Johann Lay <avr at gjlay dot de> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |eric.weddington at atmel | |dot com --- Comment #2 from Georg-Johann Lay <avr at gjlay dot de> 2011-03-12 13:01:13 UTC --- I can not confirm the problems for WinAVR-20071221 (gcc 4.2.2) With the following function int32_t test_mul (void) { int32_t res = mul_16_8(0x1234, 0x56); return res; } Both the generated code and the result of the computation (400760 in that specific case) are as expected. Presumably there is an error in your code outside the snippet (which we aren't allowed to see), maybe some signed/undigned clashes, promotion problems, overflows, etc. The code compiles with -S -Os -mmcu=atmega88 -fverbose-asm to <asm> test_mul: /* prologue: frame size=0 */ /* prologue end (size=0) */ ldi r24,lo8(4660) ; tmp43, ldi r25,hi8(4660) ; tmp43, ldi r18,lo8(86) ; tmp44, movw r20,r24 ; , tmp43 /* #APP */ clr r24; ; res clr r25; ; res mul r20, r18; ; , tmp44 movw r22, r0; ; res mul r21, r18; ; , tmp44 add r23, r0; ; res adc r24, r1; ; res clr __zero_reg__ /* #NOAPP */ /* epilogue: frame size=0 */ ret </asm> which is correct. gcc respects the early-clobber, i.e. the output operand (r22-r25) does not overlap an input operand (r20-r21 and r18). IMO this bug is invalid and can be closed. Johann