4 typedef unsigned long long int ULong
;
5 typedef unsigned int UInt
;
7 __attribute__((noinline
))
8 void do_lzcnt64 ( /*OUT*/UInt
* flags
, /*OUT*/ULong
* res
, ULong arg
)
10 ULong block
[3] = { arg
, 0ULL, 0ULL };
12 "movabsq $0x5555555555555555, %%r11" "\n\t"
13 "lzcntq 0(%0), %%r11" "\n\t"
14 "movq %%r11, 8(%0)" "\n\t"
17 "movq %%r11, 16(%0)" "\n"
18 : : "r"(&block
[0]) : "r11","cc","memory"
21 *flags
= block
[2] & 0x8d5;
24 __attribute__((noinline
))
25 void do_lzcnt32 ( /*OUT*/UInt
* flags
, /*OUT*/ULong
* res
, ULong arg
)
27 ULong block
[3] = { arg
, 0ULL, 0ULL };
29 "movabsq $0x5555555555555555, %%r11" "\n\t"
30 "lzcntl 0(%0), %%r11d" "\n\t"
31 "movq %%r11, 8(%0)" "\n\t"
34 "movq %%r11, 16(%0)" "\n"
35 : : "r"(&block
[0]) : "r11","cc","memory"
38 *flags
= block
[2] & 0x8d5;
41 __attribute__((noinline
))
42 void do_lzcnt16 ( /*OUT*/UInt
* flags
, /*OUT*/ULong
* res
, ULong arg
)
44 ULong block
[3] = { arg
, 0ULL, 0ULL };
46 "movabsq $0x5555555555555555, %%r11" "\n\t"
47 "lzcntw 0(%0), %%r11w" "\n\t"
48 "movq %%r11, 8(%0)" "\n\t"
51 "movq %%r11, 16(%0)" "\n"
52 : : "r"(&block
[0]) : "r11","cc","memory"
55 *flags
= block
[2] & 0x8d5;
62 w
= 0xFEDC192837475675ULL
;
66 do_lzcnt64(&flags
, &res
, w
);
67 printf("lzcntq %016llx -> %016llx %04x\n", w
, res
, flags
);
69 w
= ((w
>> 2) | (w
>> 1)) + (w
/ 17ULL);
72 w
= 0xFEDC192837475675ULL
;
76 do_lzcnt32(&flags
, &res
, w
);
77 printf("lzcntl %016llx -> %016llx %04x\n", w
, res
, flags
);
79 w
= ((w
>> 2) | (w
>> 1)) + (w
/ 17ULL);
82 w
= 0xFEDC192837475675ULL
;
86 do_lzcnt16(&flags
, &res
, w
);
87 printf("lzcntw %016llx -> %016llx %04x\n", w
, res
, flags
);
89 w
= ((w
>> 2) | (w
>> 1)) + (w
/ 17ULL);