Commit 53e0077e by Bob Wilson Committed by Bob Wilson

lib1funcs.asm (__udivsi3, __divsi3): Rearrange special case code to avoid one move instruction.

	* config/xtensa/lib1funcs.asm (__udivsi3, __divsi3): Rearrange special
	case code to avoid one move instruction.
	(__umodsi3, __modsi3): Merge duplicated code sequences.

From-SVN: r99520
parent ee58dffd
2005-05-10 Bob Wilson <bob.wilson@acm.org>
* config/xtensa/lib1funcs.asm (__udivsi3, __divsi3): Rearrange special
case code to avoid one move instruction.
(__umodsi3, __modsi3): Merge duplicated code sequences.
2005-05-10 Kazu Hirata <kazu@cs.umass.edu> 2005-05-10 Kazu Hirata <kazu@cs.umass.edu>
* config/mips/24k.md, config/sh/divtab.c, config/sh/sh.c, * config/mips/24k.md, config/sh/divtab.c, config/sh/sh.c,
......
...@@ -299,19 +299,21 @@ __udivsi3: ...@@ -299,19 +299,21 @@ __udivsi3:
.Lreturn: .Lreturn:
abi_return abi_return
.Lle_one:
beqz a3, .Lerror # if divisor == 1, return the dividend
abi_return
.Lspecial: .Lspecial:
# return dividend >= divisor # return dividend >= divisor
movi a2, 0 bltu a6, a3, .Lreturn0
bltu a6, a3, .Lreturn2
movi a2, 1 movi a2, 1
.Lreturn2:
abi_return abi_return
.Lle_one:
beqz a3, .Lerror # if divisor == 1, return the dividend
abi_return
.Lerror: .Lerror:
movi a2, 0 # just return 0; could throw an exception # just return 0; could throw an exception
.Lreturn0:
movi a2, 0
abi_return abi_return
.size __udivsi3,.-__udivsi3 .size __udivsi3,.-__udivsi3
...@@ -361,22 +363,24 @@ __divsi3: ...@@ -361,22 +363,24 @@ __divsi3:
movltz a2, a5, a7 # return (sign < 0) ? -quotient : quotient movltz a2, a5, a7 # return (sign < 0) ? -quotient : quotient
abi_return abi_return
.Lle_one:
beqz a3, .Lerror
neg a2, a6 # if udivisor == 1, then return...
movgez a2, a6, a7 # (sign < 0) ? -udividend : udividend
abi_return
.Lspecial: .Lspecial:
movi a2, 0 bltu a6, a3, .Lreturn0 # if dividend < divisor, return 0
bltu a6, a3, .Lreturn2 # if dividend < divisor, return 0
movi a2, 1 movi a2, 1
movi a4, -1 movi a4, -1
movltz a2, a4, a7 # else return (sign < 0) ? -1 : 1 movltz a2, a4, a7 # else return (sign < 0) ? -1 : 1
.Lreturn2:
abi_return abi_return
.Lle_one:
beqz a3, .Lerror
neg a2, a6 # if udivisor == 1, then return...
movgez a2, a6, a7 # (sign < 0) ? -udividend : udividend
abi_return
.Lerror: .Lerror:
movi a2, 0 # just return 0; could throw an exception # just return 0; could throw an exception
.Lreturn0:
movi a2, 0
abi_return abi_return
.size __divsi3,.-__divsi3 .size __divsi3,.-__divsi3
...@@ -414,17 +418,12 @@ __umodsi3: ...@@ -414,17 +418,12 @@ __umodsi3:
#endif /* !XCHAL_HAVE_LOOPS */ #endif /* !XCHAL_HAVE_LOOPS */
.Lloopend: .Lloopend:
.Lspecial:
bltu a2, a3, .Lreturn bltu a2, a3, .Lreturn
sub a2, a2, a3 # subtract once more if dividend >= divisor sub a2, a2, a3 # subtract once more if dividend >= divisor
.Lreturn: .Lreturn:
abi_return abi_return
.Lspecial:
bltu a2, a3, .Lreturn2
sub a2, a2, a3 # subtract once if dividend >= divisor
.Lreturn2:
abi_return
.Lle_one: .Lle_one:
# the divisor is either 0 or 1, so just return 0. # the divisor is either 0 or 1, so just return 0.
# someday we may want to throw an exception if the divisor is 0. # someday we may want to throw an exception if the divisor is 0.
...@@ -468,6 +467,7 @@ __modsi3: ...@@ -468,6 +467,7 @@ __modsi3:
#endif /* !XCHAL_HAVE_LOOPS */ #endif /* !XCHAL_HAVE_LOOPS */
.Lloopend: .Lloopend:
.Lspecial:
bltu a2, a3, .Lreturn bltu a2, a3, .Lreturn
sub a2, a2, a3 # subtract once more if udividend >= udivisor sub a2, a2, a3 # subtract once more if udividend >= udivisor
.Lreturn: .Lreturn:
...@@ -476,15 +476,6 @@ __modsi3: ...@@ -476,15 +476,6 @@ __modsi3:
.Lpositive: .Lpositive:
abi_return abi_return
.Lspecial:
bltu a2, a3, .Lreturn2
sub a2, a2, a3 # subtract once if dividend >= divisor
.Lreturn2:
bgez a7, .Lpositive2
neg a2, a2 # if (dividend < 0), return -udividend
.Lpositive2:
abi_return
.Lle_one: .Lle_one:
# udivisor is either 0 or 1, so just return 0. # udivisor is either 0 or 1, so just return 0.
# someday we may want to throw an exception if udivisor is 0. # someday we may want to throw an exception if udivisor is 0.
......
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