[patch] AVR __mulhi3 fix

Marek Michalkiewicz marekm@amelek.gda.pl
Wed Mar 28 09:16:00 GMT 2001


I've just applied this, for now to the 3.1 tree - fixes an old but
serious bug (513 * 1 = 1) so I'm afraid it should go into 3.0 as well...


2001-03-28  Marek Michalkiewicz  <marekm@linux.org.pl>

	* config/avr/libgcc.S (__mulhi3): Correct tests to exit the loop
	when multiplier or multiplicand is zero.


Index: config/avr/libgcc.S
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/avr/libgcc.S,v
retrieving revision 1.11
diff -c -3 -p -r1.11 libgcc.S
*** libgcc.S	2001/01/21 07:08:46	1.11
--- libgcc.S	2001/03/28 17:00:46
*************** __mulhi3_skip1:	
*** 137,147 ****
  	add	r_arg2L,r_arg2L	; shift multiplicand
  	adc	r_arg2H,r_arg2H
  
! 	cpc	r_arg2L,__zero_reg__
  	breq	__mulhi3_exit	; while multiplicand != 0
  
  	lsr	r_arg1H		; gets LSB of multiplier
  	ror	r_arg1L
  	cpc	r_arg1H,__zero_reg__
  	brne	__mulhi3_loop	; exit if multiplier = 0
  __mulhi3_exit:
--- 137,149 ----
  	add	r_arg2L,r_arg2L	; shift multiplicand
  	adc	r_arg2H,r_arg2H
  
! 	cp	r_arg2L,__zero_reg__
! 	cpc	r_arg2H,__zero_reg__
  	breq	__mulhi3_exit	; while multiplicand != 0
  
  	lsr	r_arg1H		; gets LSB of multiplier
  	ror	r_arg1L
+ 	cp	r_arg1L,__zero_reg__
  	cpc	r_arg1H,__zero_reg__
  	brne	__mulhi3_loop	; exit if multiplier = 0
  __mulhi3_exit:



More information about the Gcc-patches mailing list