3 ms·
This gets rid of the false dependency problem. Not a shining example of simplicity or reliability. But, interesting that it works. struct A { RES64 cnt0;
by corysama 11y ago
This gets rid of the false dependency problem. Not a shining example of simplicity or reliability. But, interesting that it works.
struct A { RES64 cnt0; RES64 cnt1; RES64 cnt2; RES64 cnt3; } a;
RES64 cnt0=0, cnt1=0, cnt2=0, cnt3=0;
SIZE_T ndqwords = len / (sizeof(RES64) * 4);
for(; ndqwords; ndqwords--) {
a.cnt0 = __popcnt64(*(RES64*)buf);
a.cnt1 = __popcnt64(*(RES64*)(buf + sizeof(RES64) ));
a.cnt2 = __popcnt64(*(RES64*)(buf + sizeof(RES64) * 2 ));
a.cnt3 = __popcnt64(*(RES64*)(buf + sizeof(RES64) * 3 ));
cnt0 += a.cnt0;
cnt1 += a.cnt1;
cnt2 += a.cnt2;
cnt3 += a.cnt3;
buf += sizeof(RES64) * 4;
}
cnt = cnt0 + cnt1 + cnt2 + cnt3;
000000013F2320C0 popcnt rax,qword ptr [r8]
000000013F2320C5 popcnt rcx,qword ptr [r8+8]
000000013F2320CB popcnt rdx,qword ptr [r8+10h]
000000013F2320D1 popcnt rbx,qword ptr [r8+18h]
000000013F2320D7 add r11,rax
000000013F2320DA add rdi,rcx
000000013F2320DD add rsi,rdx
000000013F2320E0 add r8,20h
000000013F2320E4 add rbp,rbx
000000013F2320E7 dec r10
000000013F2320EA jne main+0D0h (13F2320C0h)