HS>CB>Unrolling can help. Pointers slow it down. I've timed it. Contrary
o
HS>CB>popular convention, pointers are _not_ automatically faster than
HS>CB>indexing.
HS>Use an average consumer machine to test out your programs then come back
wit
HS>results.
And what is an 'average' consumer machine? Most likely a 486 or 586
machine. Those two are at least 95% of the all the PCs used in the
world. And then what is the 'average' consumer CPU in that 'average'
consumer machine? Every different one will behave differently and
different pieces of code will be 'optimal'.
As I have a fairly typical low end 486 (a 486/66, 20megs and 128k L2
cache), it is indeed fairly safe to say I have a typical computer. And
as I used DJGPP for my tests, it's also safe to say I used a typical
compiler. And got very very different results than what you did. Which
is the point.... low level optimizations are not reliable in their
benefit.
HS>lies!
HS>-O3 unrolls no loops.
No, not a lie. An error, yes. -O3 adds automatic function inlining and
I was thinking it was basic loop unrolling.
HS>CB>Yes it does use a register. But even on the register poor x86
HS>CB>architecture, most compilers will keep all three variables in
egisters.
HS>CB>Only my 8 year old QC20 doesn't bother to keep _any_ of them in
HS>CB>registers.
HS>lies!
I checked my code. I know what mine does and does not do. And quite
obviously, it's different from yours. Which is sort of the point.... It
makes it very very hard to optimize source for any particular compiler
or CPU.
I used a very typical DJGPP. Widely available (discussion of DJGPP was
the source of this thread). And it can certainly keep them in
registers. The x86 has enough registers that it is able to keep the
only 3 variables in that piece of code in registers.
HS>With optimizations turned on, my compiler removes unused variables from
HS>registers which can be used for something else.
.......... Well, all compilers should "removes unused variables from
registers". No optimizing compiler would assign an unused variable to a
register.
But as to what is and is not kept in registers depends on the compilers,
and on something as simple as that example I gave, the odds are very
very good that a compiler will be able to keep all three key variables
in registers.
--- QScan/PCB v1.19b / 01-0162
---------------
* Origin: Jackalope Junction 501-785-5381 Ft Smith AR (1:3822/1)
|