[fpc-devel] More peephole

Martin Frb lazarus at mfriebe.de
Wed Jan 22 04:06:41 CET 2014


On 21/01/2014 21:28, Florian Klämpfl wrote:
> Can you post some example code? It might be worth to think about
> improving this already in at the node level.
>

While getting examples, another issue:


with -O2 , -O3 or -O4

Note the
     movl    %eax,%edx
     movl    %edx,%eax

with -O1 it is
     movl    %eax,-4(%ebp)
     movl    -4(%ebp),%eax



.section .text.n_p$project1$_$tfoo_$__$$_init,"x"
     .balign 16,0x90
.globl    P$PROJECT1$_$TFOO_$__$$_INIT
P$PROJECT1$_$TFOO_$__$$_INIT:
# Temps allocated between esp+0 and esp+0
# Var $self located in register edx
# [19] begin
     movl    %eax,%edx
# Var $self located in register edx
# [20] Init;
     movl    %edx,%eax
     movl    (%edx),%edx
     call    *100(%edx)
# [21] end;
     ret

program project1;
{$mode objfpc}

type
   { TFoo }

   TFoo = class
     a,b : Integer;
     function Bar: Boolean;
     procedure Init; virtual;
   end;

function TFoo.Bar: Boolean;
begin
   Result := a <> b;
end;

procedure TFoo.Init;
begin
   Init;
end;

{ TFoo }


begin
end.




More information about the fpc-devel mailing list