peephole new opt for: load and immediately overwrite register
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:
The code below compiled with -O3 or -O4 produces
# [13] begin # Var i located in register eax # [14] i := 1; movl $1,%eax # Var i located in register eax # [15] i := i + 1; movl $2,%eax
The first movl can be dropped.
Attached patch does this.
It misses the comment about the allocated register though. (any hint how to identify?) AFTER: # [13] begin # Var i located in register eax # Var i located in register eax # [15] i := i + 1; movl $2,%eax
The 2nd patch can (hopefully) be used if issue #25586 (closed) has been applied first.
Additional information:
program project1;
{$mode objfpc}
type
TFoo = class
o1,o2,o3,o4,o5: TFoo;
procedure Abc; virtual;
end;
procedure TFoo.Abc;
var
i: Integer;
begin
i := 1;
i := i + 1;
end;
begin
end.
Mantis conversion info:
- Mantis ID: 25587
- OS: win
- OS Build: vista
- Build: 26519
- Platform: w32