Passing a variable by reference to an empty (inline) procedure makes it no longer placed in a register
Original Reporter info from Mantis: SergeAnvarov @SergeAnvarov
-
Reporter name: Serge Anvarov
Original Reporter info from Mantis: SergeAnvarov @SergeAnvarov
- Reporter name: Serge Anvarov
Description:
When the compiler sees a call to another procedure, it stops placing the variable in the register, even if it doesn't affect the result.
In the example below, if you uncomment a dummy procedure call, optimization will stop, as you can see from the measurement results - almost 7 times slower (tested on Win64).
Steps to reproduce:
{$APPTYPE CONSOLE}
{$MODE OBJFPC}
uses SysUtils;
procedure Dummy(var Value: Int64); inline;
begin
end;
procedure Test;
var
Value: Int64;
Ticks: QWord;
i: SizeInt;
begin
Ticks := GetTickCount64;
Value := 1;
for i := 1 to 1000*1000*1000 do
Inc(Value);
WriteLn(GetTickCount64 - Ticks);
//Dummy(Value);
end;
begin
Test;
ReadLn;
end.
Mantis conversion info:
- Mantis ID: 37282
- Platform: Windows
- Version: 3.0.4