This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] h8300/lib1funcs.asm: Optimize ___udivsi3 and ___umodsi3.


Hi,

Attached is a patch to optimize ___udivsi3 and ___umodsi3.

___udivsi3 and ___umodsi3 do not need any sign-related adjustment at
the end.

Tested on h8300 port.  Committed.

Kazu Hirata

2003-11-13  Kazu Hirata  <kazu@cs.umass.edu>

	* config/h8300/lib1funcs.asm (___udivsi3): Jump to reti
	instead of exitdiv.
	(___umodsi3): Likewise.
	(exitdiv): Do not restore any register.
	(reti): Restore registers.

Index: lib1funcs.asm
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/h8300/lib1funcs.asm,v
retrieving revision 1.23
diff -u -r1.23 lib1funcs.asm
--- lib1funcs.asm	13 Nov 2003 19:46:01 -0000	1.23
+++ lib1funcs.asm	13 Nov 2003 20:29:07 -0000
@@ -452,9 +452,8 @@
 	PUSHP	S2P
 	PUSHP	S0P
 	PUSHP	S1P
-	mov.b	#0,S2L	; keep sign low
 	bsr	divmodsi4
-	bra	exitdiv
+	bra	reti
 #else
 	;; H8/300H and H8S version of divmodsi4 does not clobber S1P or S2P.
 	PUSHP	S0P
@@ -469,11 +468,10 @@
 	PUSHP	S2P
 	PUSHP	S0P
 	PUSHP	S1P
-	mov.b	#0,S2L	; keep sign low
 	bsr	divmodsi4
 	mov	S0,A0
 	mov	S1,A1
-	bra	exitdiv
+	bra	reti
 #else
 	;; H8/300H and H8S version of divmodsi4 does not clobber S1P or S2P.
 	PUSHP	S0P
@@ -493,9 +491,6 @@
 
 	; examine what the sign should be
 exitdiv:
-	POPP	S1P
-	POPP	S0P
-
 	or	S2L,S2L
 	beq	reti
 
@@ -515,6 +510,8 @@
 #endif
 
 reti:
+	POPP	S1P
+	POPP	S0P
 	POPP	S2P
 	rts
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]