On 03.08.2013 09:36, Sven Barth wrote:
Am 02.08.2013 23:26 schrieb "Florian Klämpfl" <[email protected]
<mailto:[email protected]>>:
 >
 > Am 02.08.2013 17:46, schrieb Sven Barth:
 > > - using an array declared as a ranged array (array[0..2] of
LongInt) the
 > > for-loop is inlined and optimized a bit (especially depending on the
 > > optimization settings), but the compiler does not yet fold the loop...
 > >
 >
 > At least I fixed loop unrolling for for-in loops.

Cool! I'll need to test that with my test code :)

Hmm... am I expecting too much or is it really not working?

=== code begin ===

program inlinetest;

{$modeswitch result}

type
  TLongIntArray = array[0..2] of LongInt;

function IsIn(aElement: LongInt; const aArray: TLongIntArray): Boolean; inline;
var
  element: LongInt;
begin
  for element in aArray do
    if element = aElement then
      Exit(True);
  Result := False;
end;


procedure Test;
const
  MyArray: TLongIntArray = (42, 48, 39);
var
  b: Boolean;
begin
  b := IsIn(42, MyArray);
end;

begin

end.

=== code end ===

Tested with -O2, -O3 and -O4 and in all cases I still have the loop.

Regards,
Sven
_______________________________________________
fpc-devel maillist  -  [email protected]
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to