Optimized intkorr() and intstore(functions) for intel 64 bits.
(Benchmarked, about 30 % faster and 50 % smaller than original)
This commit is contained in:
parent
2ebc2eef8a
commit
076aa182c2
@ -16,6 +16,7 @@
|
|||||||
/*
|
/*
|
||||||
Optimized function-like macros for the x86 architecture (_WIN32 included).
|
Optimized function-like macros for the x86 architecture (_WIN32 included).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define sint2korr(A) (int16) (*((int16 *) (A)))
|
#define sint2korr(A) (int16) (*((int16 *) (A)))
|
||||||
#define sint3korr(A) ((int32) ((((uchar) (A)[2]) & 128) ? \
|
#define sint3korr(A) ((int32) ((((uchar) (A)[2]) & 128) ? \
|
||||||
(((uint32) 255L << 24) | \
|
(((uint32) 255L << 24) | \
|
||||||
@ -39,17 +40,21 @@
|
|||||||
#define uint3korr(A) (uint32) (*((unsigned int *) (A)) & 0xFFFFFF)
|
#define uint3korr(A) (uint32) (*((unsigned int *) (A)) & 0xFFFFFF)
|
||||||
#endif
|
#endif
|
||||||
#define uint4korr(A) (uint32) (*((uint32 *) (A)))
|
#define uint4korr(A) (uint32) (*((uint32 *) (A)))
|
||||||
#define uint5korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\
|
|
||||||
(((uint32) ((uchar) (A)[1])) << 8) +\
|
|
||||||
(((uint32) ((uchar) (A)[2])) << 16) +\
|
static inline ulonglong uint5korr(const void *p)
|
||||||
(((uint32) ((uchar) (A)[3])) << 24)) +\
|
{
|
||||||
(((ulonglong) ((uchar) (A)[4])) << 32))
|
ulonglong a= *(uint32 *) p;
|
||||||
#define uint6korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) + \
|
ulonglong b= *(4 + (uchar *) p);
|
||||||
(((uint32) ((uchar) (A)[1])) << 8) + \
|
return a | (b << 32);
|
||||||
(((uint32) ((uchar) (A)[2])) << 16) + \
|
}
|
||||||
(((uint32) ((uchar) (A)[3])) << 24)) + \
|
static inline ulonglong uint6korr(const void *p)
|
||||||
(((ulonglong) ((uchar) (A)[4])) << 32) + \
|
{
|
||||||
(((ulonglong) ((uchar) (A)[5])) << 40))
|
ulonglong a= *(uint32 *) p;
|
||||||
|
ulonglong b= *(uint16 *) (4 + (char *) p);
|
||||||
|
return a | (b << 32);
|
||||||
|
}
|
||||||
|
|
||||||
#define uint8korr(A) (ulonglong) (*((ulonglong *) (A)))
|
#define uint8korr(A) (ulonglong) (*((ulonglong *) (A)))
|
||||||
#define sint8korr(A) (longlong) (*((longlong *) (A)))
|
#define sint8korr(A) (longlong) (*((longlong *) (A)))
|
||||||
|
|
||||||
@ -61,23 +66,67 @@
|
|||||||
*(T+1)=(uchar) (((uint) (A) >> 8));\
|
*(T+1)=(uchar) (((uint) (A) >> 8));\
|
||||||
*(T+2)=(uchar) (((A) >> 16));\
|
*(T+2)=(uchar) (((A) >> 16));\
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define int4store(T,A) do { uchar *pT= (uchar*)(T);\
|
#define int4store(T,A) do { uchar *pT= (uchar*)(T);\
|
||||||
*((uint32 *) (pT))= (uint32) (A); \
|
*((uint32 *) (pT))= (uint32) (A); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define int5store(T,A) do { *(T)= (uchar)((A));\
|
#define int5store(T,A) do { uchar *pT= (uchar*)(T);\
|
||||||
*((T)+1)=(uchar) (((A) >> 8));\
|
*((uint32 *) (pT))= (uint32) (A); \
|
||||||
*((T)+2)=(uchar) (((A) >> 16));\
|
*((pT)+4)=(uchar) (((A) >> 32));\
|
||||||
*((T)+3)=(uchar) (((A) >> 24));\
|
} while (0)
|
||||||
*((T)+4)=(uchar) (((A) >> 32));\
|
|
||||||
} while(0)
|
#define int6store(T,A) do { uchar *pT= (uchar*)(T);\
|
||||||
#define int6store(T,A) do { *(T)= (uchar)((A)); \
|
*((uint32 *) (pT))= (uint32) (A); \
|
||||||
*((T)+1)=(uchar) (((A) >> 8)); \
|
*((uint16*)(pT+4))= (uint16) (A >> 32);\
|
||||||
*((T)+2)=(uchar) (((A) >> 16)); \
|
} while (0)
|
||||||
*((T)+3)=(uchar) (((A) >> 24)); \
|
|
||||||
*((T)+4)=(uchar) (((A) >> 32)); \
|
|
||||||
*((T)+5)=(uchar) (((A) >> 40)); \
|
|
||||||
} while(0)
|
|
||||||
#define int8store(T,A) do { uchar *pT= (uchar*)(T);\
|
#define int8store(T,A) do { uchar *pT= (uchar*)(T);\
|
||||||
*((ulonglong *) (pT))= (ulonglong) (A);\
|
*((ulonglong *) (pT))= (ulonglong) (A);\
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
|
#if defined(__GNUC__)
|
||||||
|
|
||||||
|
#define HAVE_mi_uint5korr
|
||||||
|
#define HAVE_mi_uint6korr
|
||||||
|
#define HAVE_mi_uint7korr
|
||||||
|
#define HAVE_mi_uint78orr
|
||||||
|
|
||||||
|
/* Read numbers stored in high-bytes-first order */
|
||||||
|
|
||||||
|
static inline ulonglong mi_uint5korr(const void *p)
|
||||||
|
{
|
||||||
|
ulonglong a= *(uint32 *) p;
|
||||||
|
ulonglong b= *(4 + (uchar *) p);
|
||||||
|
ulonglong v= (a | (b << 32)) << 24;
|
||||||
|
asm ("bswapq %0" : "=r" (v) : "0" (v));
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline ulonglong mi_uint6korr(const void *p)
|
||||||
|
{
|
||||||
|
ulonglong a= *(uint32 *) p;
|
||||||
|
ulonglong b= *(uint16 *) (4 + (char *) p);
|
||||||
|
ulonglong v= (a | (b << 32)) << 16;
|
||||||
|
asm ("bswapq %0" : "=r" (v) : "0" (v));
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline ulonglong mi_uint7korr(const void *p)
|
||||||
|
{
|
||||||
|
ulonglong a= *(uint32 *) p;
|
||||||
|
ulonglong b= *(uint16 *) (4 + (char *) p);
|
||||||
|
ulonglong c= *(6 + (uchar *) p);
|
||||||
|
ulonglong v= (a | (b << 32) | (c << 48)) << 8;
|
||||||
|
asm ("bswapq %0" : "=r" (v) : "0" (v));
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline ulonglong mi_uint8korr(const void *p)
|
||||||
|
{
|
||||||
|
ulonglong v= *(ulonglong *) p;
|
||||||
|
asm ("bswapq %0" : "=r" (v) : "0" (v));
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@ -52,11 +52,16 @@
|
|||||||
(((uint32) (((const uchar*) (A))[2])) << 8) +\
|
(((uint32) (((const uchar*) (A))[2])) << 8) +\
|
||||||
(((uint32) (((const uchar*) (A))[1])) << 16) +\
|
(((uint32) (((const uchar*) (A))[1])) << 16) +\
|
||||||
(((uint32) (((const uchar*) (A))[0])) << 24)))
|
(((uint32) (((const uchar*) (A))[0])) << 24)))
|
||||||
|
|
||||||
|
#ifndef HAVE_mi_uint5korr
|
||||||
#define mi_uint5korr(A) ((ulonglong)(((uint32) (((const uchar*) (A))[4])) +\
|
#define mi_uint5korr(A) ((ulonglong)(((uint32) (((const uchar*) (A))[4])) +\
|
||||||
(((uint32) (((const uchar*) (A))[3])) << 8) +\
|
(((uint32) (((const uchar*) (A))[3])) << 8) +\
|
||||||
(((uint32) (((const uchar*) (A))[2])) << 16) +\
|
(((uint32) (((const uchar*) (A))[2])) << 16) +\
|
||||||
(((uint32) (((const uchar*) (A))[1])) << 24)) +\
|
(((uint32) (((const uchar*) (A))[1])) << 24)) +\
|
||||||
(((ulonglong) (((const uchar*) (A))[0])) << 32))
|
(((ulonglong) (((const uchar*) (A))[0])) << 32))
|
||||||
|
#endif /* HAVE_mi_uint5korr */
|
||||||
|
|
||||||
|
#ifndef HAVE_mi_uint6korr
|
||||||
#define mi_uint6korr(A) ((ulonglong)(((uint32) (((const uchar*) (A))[5])) +\
|
#define mi_uint6korr(A) ((ulonglong)(((uint32) (((const uchar*) (A))[5])) +\
|
||||||
(((uint32) (((const uchar*) (A))[4])) << 8) +\
|
(((uint32) (((const uchar*) (A))[4])) << 8) +\
|
||||||
(((uint32) (((const uchar*) (A))[3])) << 16) +\
|
(((uint32) (((const uchar*) (A))[3])) << 16) +\
|
||||||
@ -64,6 +69,9 @@
|
|||||||
(((ulonglong) (((uint32) (((const uchar*) (A))[1])) +\
|
(((ulonglong) (((uint32) (((const uchar*) (A))[1])) +\
|
||||||
(((uint32) (((const uchar*) (A))[0]) << 8)))) <<\
|
(((uint32) (((const uchar*) (A))[0]) << 8)))) <<\
|
||||||
32))
|
32))
|
||||||
|
#endif /* HAVE_mi_uint6korr */
|
||||||
|
|
||||||
|
#ifndef HAVE_mi_uint7korr
|
||||||
#define mi_uint7korr(A) ((ulonglong)(((uint32) (((const uchar*) (A))[6])) +\
|
#define mi_uint7korr(A) ((ulonglong)(((uint32) (((const uchar*) (A))[6])) +\
|
||||||
(((uint32) (((const uchar*) (A))[5])) << 8) +\
|
(((uint32) (((const uchar*) (A))[5])) << 8) +\
|
||||||
(((uint32) (((const uchar*) (A))[4])) << 16) +\
|
(((uint32) (((const uchar*) (A))[4])) << 16) +\
|
||||||
@ -72,6 +80,9 @@
|
|||||||
(((uint32) (((const uchar*) (A))[1])) << 8) +\
|
(((uint32) (((const uchar*) (A))[1])) << 8) +\
|
||||||
(((uint32) (((const uchar*) (A))[0])) << 16))) <<\
|
(((uint32) (((const uchar*) (A))[0])) << 16))) <<\
|
||||||
32))
|
32))
|
||||||
|
#endif /* HAVE_mi_uint7korr */
|
||||||
|
|
||||||
|
#ifndef HAVE_mi_uint8korr
|
||||||
#define mi_uint8korr(A) ((ulonglong)(((uint32) (((const uchar*) (A))[7])) +\
|
#define mi_uint8korr(A) ((ulonglong)(((uint32) (((const uchar*) (A))[7])) +\
|
||||||
(((uint32) (((const uchar*) (A))[6])) << 8) +\
|
(((uint32) (((const uchar*) (A))[6])) << 8) +\
|
||||||
(((uint32) (((const uchar*) (A))[5])) << 16) +\
|
(((uint32) (((const uchar*) (A))[5])) << 16) +\
|
||||||
@ -81,6 +92,7 @@
|
|||||||
(((uint32) (((const uchar*) (A))[1])) << 16) +\
|
(((uint32) (((const uchar*) (A))[1])) << 16) +\
|
||||||
(((uint32) (((const uchar*) (A))[0])) << 24))) <<\
|
(((uint32) (((const uchar*) (A))[0])) << 24))) <<\
|
||||||
32))
|
32))
|
||||||
|
#endif /* HAVE_mi_uint8korr */
|
||||||
|
|
||||||
/* This one is for uniformity */
|
/* This one is for uniformity */
|
||||||
#define mi_int1store(T,A) *((uchar*)(T))= (uchar) (A)
|
#define mi_int1store(T,A) *((uchar*)(T))= (uchar) (A)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user