[fpc-devel] generated assembler code

Martin Frb lazarus at mfriebe.de
Tue May 19 15:14:54 CEST 2015


fpc 3.1.1  on i386
-O3

function FOO: Boolean;  inline;
begin
   Result := FMem <> nil;
end;

function BAR: TPItemT;
begin
   if FOO
   then Result := nil
   else Result := TPItemT(FMem.FirstItemPointer + (Index * 
FItemSize.ItemSize));
end;

generates something like:

005EACF0 833A00                   cmp dword ptr [edx],$00
005EACF3 0F95C0                   setnz al
005EACF6 84C0                     test al,al
005EACF8 7509                     jnz +$09

Is that something that should be optimized away?

al represents the nz flag

test al,al restores the nz flag, to what it already is. hat seems pointless.



More information about the fpc-devel mailing list