View Issue Details

IDProjectCategoryView StatusLast Update
0023595FPCCompilerpublic2020-09-30 21:33
Reportersanyin Assigned ToFlorian  
PrioritynormalSeverityfeatureReproducibilityalways
Status resolvedResolutionfixed 
Product Version2.7.1 
Fixed in Version3.3.1 
Summary0023595: Inefficient FPU code
DescriptionFPC 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)
TagsNo tags attached.
Fixed in Revision47024
FPCOldBugId
FPCTarget-
Attached Files

Activities

sanyin

2013-01-06 20:23

reporter   ~0064689

this code is very optimized until compiler reaches "a[i + 1] := a[i];"

Issue History

Date Modified Username Field Change
2013-01-06 20:21 sanyin New Issue
2013-01-06 20:23 sanyin Note Added: 0064689
2020-09-30 21:33 Florian Assigned To => Florian
2020-09-30 21:33 Florian Status new => resolved
2020-09-30 21:33 Florian Resolution open => fixed
2020-09-30 21:33 Florian Fixed in Version => 3.3.1
2020-09-30 21:33 Florian Fixed in Revision => 47024
2020-09-30 21:33 Florian FPCTarget => -