Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!decwrl!sgi!ciemo@bananapc.wpd.sgi.com.SGI.COM From: ciemo@bananapc.wpd.sgi.com.SGI.COM (Dave Ciemiewicz) Newsgroups: comp.sys.sgi Subject: Array indexes vs. Pointers Keywords: C optimizers Message-ID: <33239@sgi.SGI.COM> Date: 19 May 89 21:48:23 GMT Sender: daemon@sgi.SGI.COM Organization: Silicon Graphics, Inc., Mountain View, CA Lines: 87 To use pointers or array indexes, that is the question. The SGI (MIPS) compilers for the 4D are optimization monsters. The optimizer is "smart" enough to recognize special case use of array indexes and convert them to pointers internally. This removes the infamous multiply within your loop when using array indices. The fact of the matter is that there are cases where use of indexes will generate more efficient code than the corresponding code using pointers. The following is a C source file which demonstrates this. ----- optimizer.c ------------------------------------------------------------- /* 1 */extern v3f(float [3]); /* 2 */ /* 3 */dovertices_indexed(float v[][3], unsigned int len) { /* 4 */ register unsigned int i; /* 5 */ /* 6 */ for (i=0; i