home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.sgi.misc
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!uwm.edu!ux1.cso.uiuc.edu!news.cso.uiuc.edu!dweber
- From: dweber@ncsa.uiuc.edu (Daniel Weber)
- Subject: C Compiler & Array subscripting
- Message-ID: <BzDw4B.82D@news.cso.uiuc.edu>
- Originator: dweber@kankakee.ncsa.uiuc.edu
- Sender: usenet@news.cso.uiuc.edu (Net Noise owner)
- Reply-To: dweber@ncsa.uiuc.edu
- Organization: National Center for Supercomputing Applications
- Date: Thu, 17 Dec 1992 03:24:10 GMT
- Lines: 33
-
-
- This is a question that can be directed towards any general C compiler,
- but for the moment, it has to deal with SGI's C compiler:
-
- I am working with some code, written by someone else, that contains a *lot*
- of math. In this code, the authors have statements like:
-
- *(R+4) = *(R+3) + h24*(55*(*(RdotS+3)) - 59*(*(RdotS+2)) + 37*(*(RdotS+1)) - 9*(*(RdotS)));
-
- I'm attempting to clean this all up so it is legible (yes, that's a cut &
- paste, no indentations here :-( ), and would like to know if using the
- following format is less efficient:
-
- R[4] = R[3] + h24*(55*RdotS[3] - 59*RdotS[2] + 37*RdotS[1] - 9*RdotS[0]);
-
- So, is subscripting like this less efficient? My guess would be that a
- smart compiler would detect that these two statements are identical, and
- produce identical object code. However, is this always true? Say the
- above code were in a loop:
-
- for (j = 0; j < bignumber; j++) {
- R[j] = ...
- -or-
- *(R+j) = ...
-
- Would a good compiler still interpret the code the same? Specifically,
- would the SGI compiler produce efficient code (with -Ox turned on)?
-
- Thanks for any help. If you have an answer, post or email, either
- way I'm happy! :-)
-
- -daniel weber
- dweber@ncsa.uiuc.edu
-