[fpc-devel] Array indexing vs. pointers
Jim Leonard
trixter at oldskool.org
Thu Nov 7 20:57:24 CET 2013
On 11/7/2013 6:21 AM, Sven Barth wrote:
> The resulting instructions depend highly on the architecture. E.g. on
> x86 and m68k for the first case a MOV/MOVE instruction with a multiplier
> will be used while on other platforms this might involve an explicit
> multiplication. Also it will depend on the optimization level you use
> (e.g. on x86 the generated code for the first case is very different
> between -O2 and -O3). In the end you'd need to calculate the instruction
> timings to know whether one of the two is really faster than the other
> (and then you can compare that later on with your own implementation to
> check whether your code or the compiler's is faster ^^)
I'm on x86. I was hoping for a little more than "profile it to find
out" (for example, if pointers are optimized to be in indexing registers
then it should be obvious that is fastest), but if I have to do that,
then I guess that's what I'll have to do.
I suppose I can just write a short program that indexes data many
different ways and then examine the asm output.
--
Jim Leonard (trixter at 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!
More information about the fpc-devel
mailing list