Simplyfied BuildInsTabMemRefSizeInfoCache
procedure BuildInsTabMemRefSizeInfoCache can be found in compiler/x86/aasmcpu.pas and tests/utils/avx/asmtestgenerator.pas. It contains the nested function bitcnt.
function bitcnt(aValue: int64): integer;
var
i: integer;
begin
result := 0;
for i := 0 to 63 do
begin
if (aValue mod 2) = 1 then
begin
inc(result);
end;
aValue := aValue shr 1;
end;
end;
It can be noticed that the function returns the same values as popcnt, except it's slower. The following patch modifies the procedure BuildInsTabMemRefSizeInfoCache in order to make it call popcnt instead of the nested bitcnt. patch.diff