@@ -0,0 +1,26 @@
+{ %CPU=i386,x86_64 }
+{ %OPT=-O2 -CpCOREAVX }
+
+var
+ X: LongWord;
+begin
+ for X := 0 to 9 do
+ if PopCnt(X) = 0 then
+ begin
+ if X <> 0 then
+ WriteLn('FAIL: PopCnt(', X, ') = 0 returned True');
+ Halt(1);
+ end;
+ end
+ else
+ if X = 0 then
+ WriteLn('FAIL: PopCnt(0) = 0 returned False');
+ WriteLn('ok');
+end.
@@ -0,0 +1,20 @@
+ X, Y: LongWord;
+ Y := PopCnt(X);
+ { Condition arranged this way so the input of PopCnt is checked first.
+ If both X and Y are zero or both X and Y are not zero, then all is well. }
+ if (X = 0) xor (Y = 0) then
+ WriteLn('FAIL: Condition implies PopCnt(', X, ') = ', Y, ' and not ', PopCnt(X));