[PATCH][ARM] CLZ optimization for clzsi2 and clzdi2
Paul Brook
paul@codesourcery.com
Thu Jun 12 17:29:00 GMT 2008
> This patch optimizes two libraries function clzsi2 and clzdi2 for
> ARM architecture v5e and above. This helps Thumb code more than ARM
> code actually. For ARM, gcc already uses the CLZ instruction instead
> of call clz*i2 functions. I've tested this patch with arm-sim for
> build with both --with-arch=v5te and without and for both ARM and
> Thumb. The C regression test produces the same results.
Sorry about the delay responding to this.
Your patch didn't handle Thumb-2 or armv6-m.
Having separate C and asm implementations seemed like more trouble than it was
worth. The code generated for the C implementation wasn't great either, so I
just implemented the whole thing in assembly. This means we can use
__builtin_clz in longlong.h, and get ffs, ctz et. al. for free.
I also took the opportunity to use a reduced size clz lookup table. This
shaves ~300 bytes off the total text size compared to the original
implementation. While the clz function is 3 instructions longer than it would
be with an 8-bit lookup, I'm hoping improved cache footprint will tend to
compensate for this.
Tested on arm-none-eabi.
Applied to svn trunk.
Paul
2008-06-12 Paul Brook <paul@codesourcery.com>
gcc/
* longlong.h (__arm__): Define count_leading_zeros.
* config/arm/lib1funcs.asm (xxh, xxl, yyh, yyl): Define.
(clzsi2, clzdi2): New functions.
* config/arm/bpabi-v6m.S (xxh, xxl, yyh, yyl): Remove.
* config/arm/bpabi.S (xxh, xxl, yyh, yyl): Remove.
* config/arm/t-strongarm-elf (LIB1ASMFUNCS): Ditto.
* config/arm/t-vxworks (LIB1ASMFUNCS): Ditto.
* config/arm/t-pe (LIB1ASMFUNCS): Ditto.
* config/arm/t-arm-elf (LIB1ASMFUNCS): Ditto.
* config/arm/t-arm-coff (LIB1ASMFUNCS): Ditto.
* config/arm/t-linux (LIB1ASMFUNCS): Ditto.
* config/arm/t-symbian (LIB1ASMFUNCS): Ditto.
* config/arm/t-wince-pe (LIB1ASMFUNCS): Ditto.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch
Type: text/x-diff
Size: 8967 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20080612/98acff7a/attachment.bin>
More information about the Gcc-patches
mailing list