diff options
author | Pavel Pisa <pisa@cmp.felk.cvut.cz> | 2003-11-13 18:10:23 +0100 |
---|---|---|
committer | Kazu Hirata <kazu@gcc.gnu.org> | 2003-11-13 17:10:23 +0000 |
commit | 148a82c8ad081d9bc615389c6a167824fdf2e2bf (patch) | |
tree | 93b4a9c6530a17dbf3e305399ae3de5a0681cddf /gcc | |
parent | 79ae853c64afa946d36d98404dadb5bcd09974a3 (diff) | |
download | gcc-148a82c8ad081d9bc615389c6a167824fdf2e2bf.zip gcc-148a82c8ad081d9bc615389c6a167824fdf2e2bf.tar.gz gcc-148a82c8ad081d9bc615389c6a167824fdf2e2bf.tar.bz2 |
lib1funcs.asm (DenHighNonZero): Optimize using the approximate quotient method.
* config/h8300/lib1funcs.asm (DenHighNonZero): Optimize using
the approximate quotient method.
Co-Authored-By: Kazu Hirata <kazu@cs.umass.edu>
From-SVN: r73550
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/config/h8300/lib1funcs.asm | 75 |
2 files changed, 56 insertions, 25 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0199852..4bf3f91 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2003-11-13 Pavel Pisa <pisa@cmp.felk.cvut.cz> + Kazu Hirata <kazu@cs.umass.edu> + + * config/h8300/lib1funcs.asm (DenHighNonZero): Optimize using + the approximate quotient method. + 2003-11-13 Richard Earnshaw <rearnsha@arm.com> * combine.c (distribute_notes): When re-distributing the notes from diff --git a/gcc/config/h8300/lib1funcs.asm b/gcc/config/h8300/lib1funcs.asm index 7ef956f..d71a11e 100644 --- a/gcc/config/h8300/lib1funcs.asm +++ b/gcc/config/h8300/lib1funcs.asm @@ -603,32 +603,57 @@ divmodsi4: extu.l S0P rts + ; er0 = er0 / er1 + ; er4 = er0 % er1 + ; trashes er1 er2 + ; expects er1 >= 2^16 DenHighNonZero: - sub.l S0P,S0P ; zero play area - mov.w A0E,A2 - mov.b A2H,S0L - mov.b A2L,A2H - mov.b A0H,A2L - mov.w A2,A0E - mov.b A0L,A0H - mov.b #0,A0L - mov.b #24,S2H ; only do 24 iterations - -nextbit: - shll.l A0P ; double the answer guess - rotxl.l S0P ; double remainder - sub.l A1P,S0P ; does it all fit? - bhs setone - - add.l A1P,S0P ; no, restore mistake - dec S2H - bne nextbit - rts - -setone: - inc A0L - dec S2H - bne nextbit + mov.l er0,er4 + mov.l er1,er2 +#ifdef __H8300H__ +divmod_L21: + shlr.l er0 + shlr.l er2 ; make divisor < 2^16 + mov.w e2,e2 + bne divmod_L21 +#else + bra divmod_L22 +divmod_L21: + shlr.l #2,er0 +divmod_L22: + shlr.l #2,er2 ; make divisor < 2^16 + mov.w e2,e2 + bne divmod_L21 + rotxl.w r2 + bcs divmod_L23 + shlr.l er0 + bra divmod_L24 +divmod_L23: + rotxr.w r2 + shlr.l #2,er0 +divmod_L24: +#endif + ;; At this point, + ;; er0 contains shifted dividend + ;; er1 contains divisor + ;; er2 contains shifted divisor + ;; er4 contains dividend, later remainder + divxu.w r2,er0 ; e0 now contains the approximate quotient (AQ) + extu.l er0 + beq divmod_L25 + subs #1,er0 ; er0 = AQ - 1 + mov.w e1,r2 + mulxu.w r0,er2 ; er2 = upper (AQ - 1) * divisor + sub.w r2,e4 ; dividend - 65536 * er2 + mov.w r1,r2 + mulxu.w r0,er2 ; compute er4 = remainder (tentative) + sub.l er2,er4 ; er4 = dividend - (AQ - 1) * divisor +divmod_L25: + cmp.l er1,er4 ; is divisor < remainder? + blo divmod_L26 + adds #1,er0 + sub.l er1,er4 ; correct the remainder +divmod_L26: rts #endif |