[fpc-pascal] Worse performance with 64bit binary

Gabor Boros mlnglsts at bgss.hu
Sat Jul 25 16:49:07 CEST 2020


Hi All,

I cannot show the real application but attached a simple example.
If compile with 3.2.0 "ppc386.exe -O3 test.pas" the execution time of 
the resulting example binary is 0.4s, and 2.2s if compile with 
"ppcx64.exe -O3 test.pas". Any idea why?

Gabor
-------------- next part --------------
{$Mode objfpc}

uses SysUtils;

function IsP(n:Integer):Boolean;
begin
  Result:=((n mod 2)=0);
end;

procedure L5;
var
  n1,n2,n3,n4,n5:Integer;
  c:Integer;
  p:array of Integer;
  i:Integer;
  pc:Integer;

begin
  c:=0;

  SetLength(p,6);
  for i:=0 to Length(p)-1 do p[i]:=0;

  for n1:=1 to 86 do
  for n2:=n1+1 to 87 do
  for n3:=n2+1 to 88 do
  for n4:=n3+1 to 89 do
  for n5:=n4+1 to 90 do
   begin
     Inc(c);
     pc:=0;
     if IsP(n1) then Inc(pc);
     if IsP(n2) then Inc(pc);
     if IsP(n3) then Inc(pc);
     if IsP(n4) then Inc(pc);
     if IsP(n5) then Inc(pc);
     Inc(p[pc]);
   end;
end;

var
  Start:TDateTime;

begin
  Start:=Now;

  L5;

  WriteLn(FormatDateTime('s.zzz',Now-Start));
end.


More information about the fpc-pascal mailing list