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: revamped integer division library code for ARM


This patch is a rework of the library code for integer div/mod on ARM.  It 
implements a simpler and faster algorithm for mod operations, adds 
optimizations for ARMv5+ with the clz instruction, implements fast paths for 
power of 2 divisors, and some other minor optimizations, plus it makes the 
code look a bit prettier (IMHO).

I've recently been directed at a similar patch that was posted here:
http://gcc.gnu.org/ml/gcc-patches/2003-09/msg00271.html

The patch above is similar in spirit to the attached patch but doesn't
address the non XScale/ARMv5 version of the code.  It also makes things
faster in few situations through a large jump table but actually slows
things down on the average case since it doesn't handle early termination
when dividend reaches zero.

The attached patch didn't cause any regression with the regular test suite.  
It also went through my own testing to exercise all possible code paths
which actually uncovered bugs that the gcc test suite didn't catch.  Tested
with both ARMv4 and ARVv5 configurations.


2003-09-10  Nicolas Pitre <nico@cam.org>

	* arm/lib1funcs.asm (ARM_DIV_MOD_BODY) split into ARM_DIV_BODY
	and ARM_MOD_BODY.
	(ARM_MOD_BODY): rewritten. added clz insns for __ARM_ARCH__ >= 5.
	(ARM_DIV_BODY): added clz insns for __ARM_ARCH__ >= 5,
	added better divisor alignment in the other case.
	(ARM_DIV2_ORDER): added, finds the order of a single bit divisor.
	(__divsi3, __udivsi3, __modsi3, __umodsi3): rewritten using the
	macros above, add fast exits for divisor >= dividend, etc.

Attachment: lib1funcs.asm_v4.diff
Description: patch file


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