re PR target/49313 (Inefficient libgcc implementations for avr)

PR target/49313
	* config/avr/lib1funcs.S (__divmodhi4, __divmodsi4): Tweak speed.

From-SVN: r181104
This commit is contained in:
Georg-Johann Lay 2011-11-07 18:08:35 +00:00 committed by Georg-Johann Lay
parent 8b42d3defd
commit 74155a6f37
2 changed files with 62 additions and 51 deletions

View File

@ -1,3 +1,8 @@
2011-11-07 Georg-Johann Lay <avr@gjlay.de>
PR target/49313
* config/avr/lib1funcs.S (__divmodhi4, __divmodsi4): Tweak speed.
2011-11-07 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> 2011-11-07 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* config.host (tmake_file): Correct comment. * config.host (tmake_file): Correct comment.

View File

@ -562,30 +562,33 @@ ENDF __udivmodhi4
#if defined (L_divmodhi4) #if defined (L_divmodhi4)
DEFUN __divmodhi4 DEFUN __divmodhi4
.global _div .global _div
_div: _div:
bst r_arg1H,7 ; store sign of dividend bst r_arg1H,7 ; store sign of dividend
mov __tmp_reg__,r_arg1H mov __tmp_reg__,r_arg2H
eor __tmp_reg__,r_arg2H ; r0.7 is sign of result brtc 0f
rcall __divmodhi4_neg1 ; dividend negative : negate com __tmp_reg__ ; r0.7 is sign of result
sbrc r_arg2H,7 rcall __divmodhi4_neg1 ; dividend negative: negate
rcall __divmodhi4_neg2 ; divisor negative : negate 0:
XCALL __udivmodhi4 ; do the unsigned div/mod sbrc r_arg2H,7
rcall __divmodhi4_neg1 ; correct remainder sign rcall __divmodhi4_neg2 ; divisor negative: negate
tst __tmp_reg__ XCALL __udivmodhi4 ; do the unsigned div/mod
brpl __divmodhi4_exit sbrc __tmp_reg__,7
__divmodhi4_neg2: rcall __divmodhi4_neg2 ; correct remainder sign
com r_arg2H brtc __divmodhi4_exit
neg r_arg2L ; correct divisor/result sign
sbci r_arg2H,0xff
__divmodhi4_exit:
ret
__divmodhi4_neg1: __divmodhi4_neg1:
brtc __divmodhi4_exit ;; correct dividend/remainder sign
com r_arg1H com r_arg1H
neg r_arg1L ; correct dividend/remainder sign neg r_arg1L
sbci r_arg1H,0xff sbci r_arg1H,0xff
ret ret
__divmodhi4_neg2:
;; correct divisor/result sign
com r_arg2H
neg r_arg2L
sbci r_arg2H,0xff
__divmodhi4_exit:
ret
ENDF __divmodhi4 ENDF __divmodhi4
#endif /* defined (L_divmodhi4) */ #endif /* defined (L_divmodhi4) */
@ -807,36 +810,39 @@ ENDF __udivmodsi4
#if defined (L_divmodsi4) #if defined (L_divmodsi4)
DEFUN __divmodsi4 DEFUN __divmodsi4
bst r_arg1HH,7 ; store sign of dividend mov __tmp_reg__,r_arg2HH
mov __tmp_reg__,r_arg1HH bst r_arg1HH,7 ; store sign of dividend
eor __tmp_reg__,r_arg2HH ; r0.7 is sign of result brtc 0f
rcall __divmodsi4_neg1 ; dividend negative : negate com __tmp_reg__ ; r0.7 is sign of result
sbrc r_arg2HH,7 rcall __divmodsi4_neg1 ; dividend negative: negate
rcall __divmodsi4_neg2 ; divisor negative : negate 0:
XCALL __udivmodsi4 ; do the unsigned div/mod sbrc r_arg2HH,7
rcall __divmodsi4_neg1 ; correct remainder sign rcall __divmodsi4_neg2 ; divisor negative: negate
rol __tmp_reg__ XCALL __udivmodsi4 ; do the unsigned div/mod
brcc __divmodsi4_exit sbrc __tmp_reg__, 7 ; correct quotient sign
__divmodsi4_neg2: rcall __divmodsi4_neg2
com r_arg2HH brtc __divmodsi4_exit ; correct remainder sign
com r_arg2HL
com r_arg2H
neg r_arg2L ; correct divisor/quotient sign
sbci r_arg2H,0xff
sbci r_arg2HL,0xff
sbci r_arg2HH,0xff
__divmodsi4_exit:
ret
__divmodsi4_neg1: __divmodsi4_neg1:
brtc __divmodsi4_exit ;; correct dividend/remainder sign
com r_arg1HH com r_arg1HH
com r_arg1HL com r_arg1HL
com r_arg1H com r_arg1H
neg r_arg1L ; correct dividend/remainder sign neg r_arg1L
sbci r_arg1H, 0xff sbci r_arg1H, 0xff
sbci r_arg1HL,0xff sbci r_arg1HL,0xff
sbci r_arg1HH,0xff sbci r_arg1HH,0xff
ret ret
__divmodsi4_neg2:
;; correct divisor/quotient sign
com r_arg2HH
com r_arg2HL
com r_arg2H
neg r_arg2L
sbci r_arg2H,0xff
sbci r_arg2HL,0xff
sbci r_arg2HH,0xff
__divmodsi4_exit:
ret
ENDF __divmodsi4 ENDF __divmodsi4
#endif /* defined (L_divmodsi4) */ #endif /* defined (L_divmodsi4) */