Commit 74155a6f by Georg-Johann Lay Committed by Georg-Johann Lay

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

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

From-SVN: r181104
parent 8b42d3de
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.
......
...@@ -562,30 +562,33 @@ ENDF __udivmodhi4 ...@@ -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
rcall __divmodhi4_neg2 ; correct remainder sign
brtc __divmodhi4_exit
__divmodhi4_neg1:
;; correct dividend/remainder sign
com r_arg1H
neg r_arg1L
sbci r_arg1H,0xff
ret
__divmodhi4_neg2: __divmodhi4_neg2:
com r_arg2H ;; correct divisor/result sign
neg r_arg2L ; correct divisor/result sign com r_arg2H
sbci r_arg2H,0xff neg r_arg2L
sbci r_arg2H,0xff
__divmodhi4_exit: __divmodhi4_exit:
ret ret
__divmodhi4_neg1:
brtc __divmodhi4_exit
com r_arg1H
neg r_arg1L ; correct dividend/remainder sign
sbci r_arg1H,0xff
ret
ENDF __divmodhi4 ENDF __divmodhi4
#endif /* defined (L_divmodhi4) */ #endif /* defined (L_divmodhi4) */
...@@ -807,36 +810,39 @@ ENDF __udivmodsi4 ...@@ -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
rcall __divmodsi4_neg2
brtc __divmodsi4_exit ; correct remainder sign
__divmodsi4_neg1:
;; 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: __divmodsi4_neg2:
com r_arg2HH ;; correct divisor/quotient sign
com r_arg2HL com r_arg2HH
com r_arg2H com r_arg2HL
neg r_arg2L ; correct divisor/quotient sign com r_arg2H
sbci r_arg2H,0xff neg r_arg2L
sbci r_arg2HL,0xff sbci r_arg2H,0xff
sbci r_arg2HH,0xff sbci r_arg2HL,0xff
sbci r_arg2HH,0xff
__divmodsi4_exit: __divmodsi4_exit:
ret ret
__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
ENDF __divmodsi4 ENDF __divmodsi4
#endif /* defined (L_divmodsi4) */ #endif /* defined (L_divmodsi4) */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment