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>
* config.host (tmake_file): Correct comment.

View File

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