This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
RE: Global variables are slower?
- To: anjul dot srivastava at sanchez dot com
- Subject: RE: Global variables are slower?
- From: John Wehle <john at feith dot com>
- Date: Fri, 11 Feb 2000 19:40:30 -0500 (EST)
- Cc: gcc at gcc dot gnu dot org
> Is it correct to summarize that if there are no function calls between
> repeated references to a non-volatile global variable, then it can be
> optimized to work as well as a local variable.
No. Consider:
int i;
int *p;
int main()
{
int a;
for (i = 0; i < 1000000; i++)
{
*p = i + 1;
a += i;
}
}
p might point to i.
-- John
-------------------------------------------------------------------------
| Feith Systems | Voice: 1-215-646-8000 | Email: john@feith.com |
| John Wehle | Fax: 1-215-540-5495 | |
-------------------------------------------------------------------------