From 59184677f448e6e760a945dd9b774ec41be0f64d Mon Sep 17 00:00:00 2001 From: Toshiyasu Morita Date: Sat, 20 Apr 2002 18:01:53 +0000 Subject: [PATCH] lib1funcs.asm (___mulsi3): Use hardware multiply instructions for H8/300H case. * config/h8300/lib1funcs.asm (___mulsi3): Use hardware multiply instructions for H8/300H case. From-SVN: r52558 --- gcc/ChangeLog | 5 +++ gcc/config/h8300/lib1funcs.asm | 65 +++++++++++++++++++++------------- 2 files changed, 46 insertions(+), 24 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5435330cac9c..63fd6350be4c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2002-04-20 Toshiyasu Morita + + * config/h8300/lib1funcs.asm (___mulsi3): Use hardware + multiply instructions for H8/300H case. + 2002-04-20 Toshiyasu Morita * config/h8300/lib1funcs.asm (___cmpsi2, ___ucmpsi2): diff --git a/gcc/config/h8300/lib1funcs.asm b/gcc/config/h8300/lib1funcs.asm index aa68ebcab373..0fbeacd0ed07 100644 --- a/gcc/config/h8300/lib1funcs.asm +++ b/gcc/config/h8300/lib1funcs.asm @@ -730,32 +730,49 @@ _done: #else /* __H8300H__ */ +; +; mulsi3 for H8/300H - based on Hitachi SH implementation +; +; by Toshiyasu Morita +; +; Old code: +; +; 16b * 16b = 372 states (worst case) +; 32b * 32b = 724 states (worst case) +; +; New code: +; +; 16b * 16b = 68 states +; 16b * 32b = 96 states +; 32b * 32b = 124 states +; + .global ___mulsi3 ___mulsi3: - sub.l A2P,A2P - - ; while (a) -_top: mov.l A0P,A0P - beq _done - - ; if (a & 1) - bld #0,A0L - bcc _nobit - - ; r += b - add.l A1P,A2P - -_nobit: - ; a >>= 1 - shlr.l A0P - - ; b <<= 1 - shll.l A1P - bra _top - -_done: - mov.l A2P,A0P - rts + push.l er3 ; (10 states) + + mov.w r1,r2 ; ( 2 states) b * d + mulxu r0,er2 ; (22 states) + + mov.w e0,r3 ; ( 2 states) a * d + beq L_skip1 ; ( 4 states) + mulxu r1,er3 ; (22 states) + mov.w r3,e3 ; ( 2 states) + mov.w #0,r3 ; ( 2 states) + add.l er3,er2 ; ( 2 states) + +L_skip1: + mov.w e1,r3 ; ( 2 states) c * b + beq L_skip2 ; ( 4 states) + mulxu r0,er3 ; (22 states) + mov.w r3,e3 ; ( 2 states) + mov.w #0,r3 ; ( 2 states) + add.l er3,er2 ; ( 2 states) + +L_skip2: + mov.l er2,er0 ; ( 2 states) + pop.l er3 ; (10 states) + rts ; (10 states) #endif #endif /* L_mulsi3 */ -- 2.43.5