Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uwm.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!usc!jarthur!nntp-server.caltech.edu!seismo.gps.caltech.edu!bruce From: bruce@seismo.gps.caltech.edu (Bruce Worden) Newsgroups: comp.lang.c Subject: Re: p[1] vs. *(p+1) Message-ID: <1990Aug31.231033.19235@laguna.ccsf.caltech.edu> Date: 31 Aug 90 23:10:33 GMT References: <26D952F5.4E44@tct.uucp> <1745@io.UUCP> <1990Aug31.190103.15043@laguna.ccsf.caltech.edu> <29605:Aug3120:51:0290@kramden.acf.nyu.edu> Sender: bruce@seismo.gps.caltech.edu (Bruce Worden) Organization: California Institute of Technology, CA Lines: 20 In article <29605:Aug3120:51:0290@kramden.acf.nyu.edu> brnstnd@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@seismo.gps.caltech.edu 252-21 Seismological Laboratory, Caltech, Pasadena, CA 91125