This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Global variables are slower?


On Fri, 11 Feb 2000 17:15:46 -0500, you wrote:

>Hello folks,
> 
>Somebody told me that accessing a global variable requires an extra
>instruction, and thus, global variables are slower than local variables.

It depends on the architecture you run your program on.

>Is this true for gcc generated code? I'm surprised if it is because I
>understood from my knowledge of C that there was no performance difference
>between local and global variables.

Your understanding of your knowledge of C is wrong. Or your knowledge of
C is wrong. Or both.

>Can it be optimized out, at least for repeated accesses, if it is true?

It can and it is.

>Anjul.

Dima

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]