p[1] vs. *(p+1)
Bruce Worden
bruce at seismo.gps.caltech.edu
Sat Sep 1 09:10:33 AEST 1990
In article <29605:Aug3120:51:0290 at kramden.acf.nyu.edu> brnstnd at kramden.acf.nyu.edu (Dan Bernstein) writes:
>Huh? p[1] means exactly the same thing as *(p+1). At least two compilers
>here (neither pcc-based) do that translation as the very first step.
>There's no ``optimization'' involved.
It is really an extremely small point. As far as I know, nothing specifies
that the code generated by the two statements has to be identical, only that
the results are the same. One could imagine a compiler that did one less
efficiently than the other.
>> *p1++ = *a1++ * *b1++;
>> p2[i] = a2[i] * b2[i];
>Note that on vector machines the latter is much faster in a loop.
My point exactly. Except that the example you give isn't necessarily
true. On our Convex both will vectorize, and the run time is the same.
--------------------------------------------------------------------------
C. Bruce Worden bruce at seismo.gps.caltech.edu
252-21 Seismological Laboratory, Caltech, Pasadena, CA 91125
More information about the Comp.lang.c
mailing list