home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / sys / sgi / misc / 18 < prev    next >
Encoding:
Text File  |  1992-12-16  |  1.7 KB  |  46 lines

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