This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Is x[2] faster to access than a scalar variable?
- To: "Joseph" <colosses at hotmail dot com>
- Subject: Re: Is x[2] faster to access than a scalar variable?
- From: Jeffrey A Law <law at cygnus dot com>
- Date: Tue, 17 Aug 1999 23:28:57 -0600
- cc: help-gcc at gnu dot org
- Reply-To: law at cygnus dot com
In message <37b5f040.0@192.117.192.1>you write:
> >int foo()
> >{
> > double x[3], y, q1;
> >
> > x[2] = 1.234;
> > y = 1.234;
> > q1 = 7.2*x[2];
> > q2 = 7.2*y;
> >}
> >
> >Is it faster to evaluate q1 or q2?
In general accessing a scalar will be more efficient than accessing a
structure or array reference as the compiler can hold scalars in registers
for a longer duration than an access to a member of an aggregate.
jeff