Re: [patch] Accelerate CAIRO_BITSWAP8 on 64 bit machines
zhigang gong <[email protected]>
| Newsgroups | gmane.comp.lib.cairo |
|---|---|
| Message-ID | <CAFfUhOX64Y0XBbLTwo+ZL=e14SWpxMi1V=CSkBXCrDxV6k6GEw@mail.gmail.com> |
On Tue, May 29, 2012 at 3:51 PM, Xing, Dongsheng <[email protected]> wrote: > -----Original Message----- > From: Chris Wilson > Sent: Tuesday, May 29, 2012 3:25 PM > To: Xing, Dongsheng; [email protected] > Subject: Re: [cairo] [patch] Accelerate CAIRO_BITSWAP8 on 64 bit machines > >> On Tue, 29 May 2012 02:03:58 +0000, "Xing, Dongsheng" wrote: >> > Hi, 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. >> >> This doesn't apply to master. Care to resend? > > OK. > > diff --git a/src/cairoint.h b/src/cairoint.h > index 2c9f2dd..d6201f3 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_LONG >= 8) > +#define CAIRO_BITSWAP8(c) ((((c) * 0x80200802LLU & 0x884422110LLU) * 0x101010101LLU) >> 32) > +#else > #define CAIRO_BITSWAP8(c) ((((c) * 0x0802LU & 0x22110LU) | ((c) * 0x8020LU & 0x88440LU)) * 0x10101LU >> 16) > +#endif > > I don't know why the patch doesn't apply to "master". > I guess the reason is my code is not the "master". Because I downloaded the code by > git clone git://anongit.freedesktop.org/git/cairo > I am not sure. > >> >> > 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) >> >> A more appropriate test here would be that "SIZEOF_LONG_LONG >= 8" as that is the condition used in the macro. > > I think SIZEOF_LONG >= 8 is better. Because sizeof(long long)==8 on a 32 bit machine. And SIZEOF_LONG is the length of a native processor word. No, SIZEOF_LONG is not always the native word size of the platform, for an example : On 64-bit Windows, sizeof(int) == sizeof(long) == 4. I prefer uintptr_t which is defeind in <stdint.h> . > > Best regards, > Dongsheng > >> >> > +#define CAIRO_BITSWAP8(c) ((((c) * 0x80200802LLU & 0x884422110LLU) * 0x101010101LLU) >> 32) >> > +#else >> > #define CAIRO_BITSWAP8(c) ((((c) * 0x0802LU & 0x22110LU) | ((c) * >> > 0x8020LU & >> > 0x88440LU)) * 0x10101LU >> 16) >> > +#endif >> >> -- >> Chris Wilson, Intel Open Source Technology Centre > -- > cairo mailing list > [email protected] > http://lists.cairographics.org/mailman/listinfo/cairo -- cairo mailing list [email protected] http://lists.cairographics.org/mailman/listinfo/cairo