Re: An article I alluded to

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Bill McEnaney" <bill@xxxxxxxxxxxx> writes:

> In another e-mail, I told you about an article that said that the
> computer can access static variables faster than it can access automatic
> variables.  So here's a link to that article.
> 
> http://www.numerix-dsp.com/appsnotes/c_coding.html

That article is very specific to DSPs.  I've seen DSPs in which there
is a limited range of memory, so that a load can be done from an
arbitrary memory address in a single instruction, and there is also no
register offset memory addressing.  Under those conditions, it is
indeed more efficient to use a static variable than to use an
automatic variable.

However, any ordinary processor has register offset memory addressing,
and on most RISC processors you can not load from an arbitrary memory
address in a single instruction (although you can on x86).  So in
these normal conditions, automatic variables will be faster.

The article is wrong to suggest using the "register" declaration, as
it is universally ignored by optimizing compilers.  Similarly with the
advice about reusing local variables.

I didn't see any other obvious errors.

Ian

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux