Re: [patch] Accelerate CAIRO_BITSWAP8 on 64 bit machines

"Xing, Dongsheng" <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <720BD6C0640BA94687C456A78160D41D12D565@SHSMSX101.ccr.corp.intel.com>
Thank Petr.

About SIZEOF(XXX):
We cannot use "#if sizeof(intptr_t)>=8" because GCC refuses to compile that code.
We have to use SIZEOF_VOID_P, but no other choice. There is only SIZEOF_VOID_P in config.h, no SIZEOF_INTPTR_XXX.

About long long:
  On Windows 64bit: [1]
  sizeof(long long) == 8, sizeof(void *) == 8
  On Linux 64bit: [2]
  sizeof(long long) == 8, sizeof(void *) == 8

Reference:
[1] http://msdn.microsoft.com/en-us/library/cc953fe1(v=vs.80).aspx;
(checked by Microsoft Visual C++ Express 2010 on Windows 7 64bit) 
[2] http://gcc.gnu.org/onlinedocs/gcc/Long-Long.html;
(checked by GCC 4.6.3 also)

Hence we use 0x80200802LLU, not 0x80200802LU.

New patch:
Description: CAIRO_BITSWAP8 costs seven operations on a 32 bit machine, but it can be done with only four operations on 64 bit  machines. This patch accelerates CAIRO_BITSWAP8 on 64 bit machines.
Signed-off-by: Dongsheng Xing <dongsheng.xing at intel.com>
---
 src/cairoint.h |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/cairoint.h b/src/cairoint.h index 2c9f2dd..7e62d86 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -169,7 +169,11 @@ do {					\
  * Devised by Sean Anderson, July 13, 2001.
  * Source: http://graphics.stanford.edu/~seander/bithacks.html#ReverseByteWith32Bits
  */
+#if (SIZEOF_VOID_P >= 8)
+#define CAIRO_BITSWAP8(c) ((((c) * 0x80200802LLU & 0x884422110LLU) * 0x101010101LLU) >> 32)
+#else
 #define CAIRO_BITSWAP8(c) ((((c) * 0x0802LU & 0x22110LU) | ((c) * 0x8020LU & 0x88440LU)) * 0x10101LU >> 16)
+#endif

 /* Return the number of 1 bits in mask.
  *
--
1.7.9.5

--
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.