Inefficient FPU code
Original Reporter info from Mantis: sanyin
-
Reporter name: sanyin
Original Reporter info from Mantis: sanyin
- Reporter name: sanyin
Description:
FPC generates very inefficient FPU code, when using "double".
procedure TestF(a, b: pdoublearray; cnt: integer);
var
i: integer;
begin
for i := 0 to cnt - 1 do
begin
a[i] := a[i] + b[i];
a[i + 1] := a[i];
end;
end;
00401569 8d7600 lea 0x0(%esi),%esi
0040156C 46 inc %esi
0040156D 89f3 mov %esi,%ebx
FloatBench1.lpr:24 a[i] := a[i] + b[i];
0040156F dd04da fldl (%edx,%ebx,8)
00401572 dc04d8 faddl (%eax,%ebx,8)
00401575 dd1cd8 fstpl (%eax,%ebx,8)
FloatBench1.lpr:25 a[i + 1] := a[i];
00401578 89f3 mov %esi,%ebx
0040157A 43 inc %ebx
0040157B 8b3cf0 mov (%eax,%esi,8),%edi <--- what about fstp?
0040157E 893cd8 mov %edi,(%eax,%ebx,8)
00401581 8b7cf004 mov 0x4(%eax,%esi,8),%edi
00401585 897cd804 mov %edi,0x4(%eax,%ebx,8)
00401589 39f1 cmp %esi,%ecx
In the code above, compiler should reuse "a[i]" (already loaded)
Mantis conversion info:
- Mantis ID: 23595
- OS Build: Win
- Version: 2.7.1
- Fixed in version: 3.3.1
- Fixed in revision: 47024 (#284aca73)