Browse Source

Add POPCNTSupport call to avoid use of unsupported instruction

Pierre Muller 1 year ago
parent
commit
a3b730b0f1
2 changed files with 16 additions and 1 deletions
  1. 8 0
      tests/test/opt/tpopcnt1.pp
  2. 8 1
      tests/test/opt/tpopcnt2.pp

+ 8 - 0
tests/test/opt/tpopcnt1.pp

@@ -1,9 +1,17 @@
 { %CPU=i386,x86_64 }
 { %OPT=-O2 -CpCOREAVX }
 
+uses
+  cpu;
+
 var
   X: LongWord;
 begin
+  if not popcntsupport then
+    begin
+      writeln('This CPU doesn''t support POPCNT instruction');
+      halt(0);
+    end;
   for X := 0 to 9 do
     if PopCnt(X) = 0 then
       begin

+ 8 - 1
tests/test/opt/tpopcnt2.pp

@@ -1,9 +1,16 @@
 { %CPU=i386,x86_64 }
 { %OPT=-O2 -CpCOREAVX }
+uses
+  cpu;
 
 var
   X, Y: LongWord;
 begin
+  if not popcntsupport then
+    begin
+      writeln('This CPU doesn''t support POPCNT instruction');
+      halt(0);
+    end;
   for X := 0 to 9 do
     begin
       Y := PopCnt(X);
@@ -17,4 +24,4 @@ begin
     end;
 
   WriteLn('ok');
-end.
+end.