4 typedef unsigned long long int ULong;
5 typedef unsigned int UInt;
7 __attribute__((noinline))
8 void do_lzcnt32 ( /*OUT*/UInt* flags, /*OUT*/UInt* res, UInt arg )
10 UInt block[3] = { arg, 0, 0 };
12 "movl $0x55555555, %%esi" "\n\t"
13 "lzcntl 0(%0), %%esi" "\n\t"
14 "movl %%esi, 4(%0)" "\n\t"
17 "movl %%esi, 8(%0)" "\n"
18 : : "r"(&block[0]) : "esi","cc","memory"
21 *flags = block[2] & 0x8d5;
24 __attribute__((noinline))
25 void do_lzcnt16 ( /*OUT*/UInt* flags, /*OUT*/UInt* res, UInt arg )
27 UInt block[3] = { arg, 0, 0 };
29 "movl $0x55555555, %%esi" "\n\t"
30 "lzcntw 0(%0), %%si" "\n\t"
31 "movl %%esi, 4(%0)" "\n\t"
34 "movl %%esi, 8(%0)" "\n"
35 : : "r"(&block[0]) : "esi","cc","memory"
38 *flags = block[2] & 0x8d5;
49 do_lzcnt32(&flags, &res, w);
50 printf("lzcntl %08x -> %08x %04x\n", w, res, flags);
52 w = ((w >> 2) | (w >> 1)) + (w / 17);
59 do_lzcnt16(&flags, &res, w);
60 printf("lzcntw %08x -> %08x %04x\n", w, res, flags);
62 w = ((w >> 2) | (w >> 1)) + (w / 17);