#include #define rdtscl(low) \ __asm__ __volatile__ ("rdtsc" : "=a" (low) : : "edx") #define MAD_F_SCALEBITS 24 #define shrd(__lo_,__hi_,__result) \ asm volatile("shrdl %3,%2,%1" \ : "=rm" (__result) \ : "0" (__lo_), "r" (__hi_), "I" (MAD_F_SCALEBITS) \ : "cc"); \ #define shrd_new(__lo_,__hi_,__result) \ asm volatile("shrl %3,%1\n\t" \ "shll %4,%2\n\t" \ "orl %2,%1\n\t" \ : "=rm" (__result) \ : "0" (__lo_), "r" (__hi_), "I" (MAD_F_SCALEBITS), \ "I" (32-MAD_F_SCALEBITS) \ : "cc"); \ void main() { long a,b,c; size_t i; int x,y,r; x=0x12345678; y=0x87654321; rdtscl(a); for (i=0; i<100; ++i) shrd(x,y,r); rdtscl(b); printf("normal: %ld (%lx)\n",b-a,r); rdtscl(a); for (i=0; i<100; ++i) shrd_new(x,y,r); rdtscl(b); printf("pointer arithmetic: %ld (%lx)\n",b-a,r); }