(Sorry if this isn't technical enough for the developer list, but it requires understanding of the underlying architecture so I thought it was appropriate.) I'm implementing something in FPC that will perform very many comparisons across sets of data, and would like to know whether or not FPC is more efficient with array indexing calculations vs. doing the pointer math myself. For example, I have a choice of doing either this:

  for b:=0 to num-1 do
    diff:=src^[b]-dst^[b];

...or this:

  for b:=0 to num-1 do begin
    diff:=src^-dst^;
    inc(src);
    inc(dst);
  end;

I read a few posts from 2010 and a post from 2013 that implies FPC's array index calcs are just a MUL and suboptimial; is this still the case? Which method produces faster code? A third way would be to copy data into a dynamic array and no pointer use at all, ie. "diff:=src[b]-dst[b];"... is this the fastest option?

(Eventually I will be writing performance-critical sections in assembler, but would like to avoid doing that during early phases of my project.)
--
Jim Leonard (trix...@oldskool.org)
Check out some trippy MindCandy: http://www.mindcandydvd.com/
A child borne of the home computer wars: http://trixter.oldskool.org/
You're all insane and trying to steal my magic bag!
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to