peephole opt (i386) add (previoulsy commented) opt, load same memory twice
Original Reporter info from Mantis: Martin @martin_frb
-
Reporter name: Martin Friebe
Original Reporter info from Mantis: Martin @martin_frb
- Reporter name: Martin Friebe
Description:
There is an old opt in the peephole for i386, that is commented.
The patch applies the necessary fixes, and activates it.
It translates
movl [mem1],reg1
movl [mem1],reg2
to
movl [mem1],reg1
movl reg1,reg2
Such code is produced by the both of below example in -O 1,2,3 and 4
There may be more examples, but some only in lower opt levels. Though that is because higher levels use registers, so to get mem loaded (and maybe trigger it) more complex code is needed.
The code after the opt is better, but not optimal, as now 2 regs have the same value, and so only one should be needed. To fix this would be way more complex, and until then this is an improvement.
--------------
The 2 patches are identical, except for indent.
The first only adds the changes, but does not change the indent of following "else" blocks. This allows to easily see the changes.
The 2nd includes that indent.
Additional information:
program project1;
{$mode objfpc}
type
TFoo = class
a,b : Integer;
constructor Create;
end;
TFoo2=class(tfoo)
constructor Create;
end;
constructor TFoo2.Create;
begin
inherited;
a:= 1;
end;
constructor TFoo.Create;
begin
b:=2;
end;
begin
end.
-----------------------------------
program project1;
{$mode objfpc}
type
TFoo = class
o1,o2,o3,o4,o5: TFoo;
procedure Abc; virtual;
procedure Bar; virtual;
end;
procedure TFoo.Abc;
begin
Bar;
o1.bar;
o2.bar;
o3.bar;
o4.bar;
o5.bar;
end;
procedure TFoo.Bar;
begin
end;
begin
end.
Mantis conversion info:
- Mantis ID: 25586
- OS: win
- OS Build: vista
- Build: 26519
- Platform: w32
- Version: 2.7.1