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]

libgcc parity optimization


Suggested by Falk the other day.


r~


        * libgcc2.c (__paritysi2, __paritydi2): Replace last two reduction
        rounds with a "bit table" lookup.

Index: libgcc2.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/libgcc2.c,v
retrieving revision 1.161
diff -c -p -d -u -r1.161 libgcc2.c
--- libgcc2.c	4 Feb 2003 21:45:40 -0000	1.161
+++ libgcc2.c	4 Feb 2003 21:49:38 -0000
@@ -664,9 +664,8 @@ __paritysi2 (USItype x)
   nx ^= nx >> 16;
   nx ^= nx >> 8;
   nx ^= nx >> 4;
-  nx ^= nx >> 2;
-  nx ^= nx >> 1;
-  return nx & 1;
+  nx &= 0xf;
+  return (0x6996 >> nx) & 1;
 }
 #endif
 
@@ -680,9 +679,8 @@ __paritydi2 (UDItype x)
   nx ^= nx >> 16;
   nx ^= nx >> 8;
   nx ^= nx >> 4;
-  nx ^= nx >> 2;
-  nx ^= nx >> 1;
-  return nx & 1;
+  nx &= 0xf;
+  return (0x6996 >> nx) & 1;
 }
 #endif
 


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