This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Global variables are slower?
- To: Anjul Srivastava <anjul dot srivastava at sanchez dot com>
- Subject: Re: Global variables are slower?
- From: dvv at egcs dot dvv dot ru (Dima Volodin)
- Date: Fri, 11 Feb 2000 22:26:09 GMT
- Cc: "'gcc at gcc dot gnu dot org'" <gcc at gcc dot gnu dot org>
- Organization: Huh?
- References: <2473C7ACA21ED211854F08002BB768C40551D060@OZ>
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