home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / sys / sun / misc / 4179 < prev    next >
Encoding:
Text File  |  1992-09-11  |  2.6 KB  |  97 lines

  1. Newsgroups: comp.sys.sun.misc
  2. Path: sparky!uunet!psinntp!ims.com!kestrel!davek
  3. From: davek@kestrel.ims.com (Dave Koon)
  4. Subject: Re: sun cc optimization failure
  5. Message-ID: <1992Sep10.163247.22854@ims.com>
  6. Sender: usenet@ims.com (USENET News Poster)
  7. Reply-To: davek@kestrel.ims.com
  8. Organization: Integrated Measurement Systems
  9. References: <etxkrjg.716039624@solsta-c>
  10. Date: Thu, 10 Sep 1992 16:32:47 GMT
  11. Lines: 84
  12.  
  13. Without sounding defensive, I wonder what the difference between what I did 
  14. and what Kristian did.
  15. *****************************************************************************
  16. zaphod:/css/davek> more test.c
  17. main() {
  18.     int i,j,ax;
  19.     ax = 0;
  20.     for(i=0;i<3;i++){
  21.         j = ax * i;
  22.         puts("in for loop");
  23.     }
  24. }
  25.  
  26. zaphod:/css/davek> more /etc/motd
  27. SunOS Release 4.1.2 (GENERIC) #2: Wed Oct 23 10:52:58 PDT 1991
  28. zaphod:/css/davek> cc test.c -o test
  29. zaphod:/css/davek> ./test
  30. in for loop
  31. in for loop
  32. in for loop
  33. zaphod:/css/davek> cc -O test.c -o test
  34. zaphod:/css/davek> ./test
  35. in for loop
  36. in for loop
  37. in for loop
  38. zaphod:/css/davek> cc -O1 test.c -o test
  39. zaphod:/css/davek> ./test
  40. in for loop
  41. in for loop
  42. in for loop
  43. zaphod:/css/davek> cc -O2 test.c -o test
  44. zaphod:/css/davek> ./test
  45. in for loop
  46. in for loop
  47. in for loop
  48. zaphod:/css/davek> cc -O3 test.c -o test
  49. zaphod:/css/davek> ./test
  50. in for loop
  51. in for loop
  52. in for loop
  53. zaphod:/css/davek> cc -O4 test.c -o test
  54. zaphod:/css/davek> ./test
  55. in for loop
  56. in for loop
  57. in for loop
  58. *******************************************************************************
  59.  
  60. In article 716039624@solsta-c, etxkrjg@solsta.ericsson.se (Kristian Jorg  TX/DKL) writes:
  61. >davek@kestrel.ims.com (Dave Koon) writes:
  62. >
  63. >>In article 16902@mr.med.ge.com, carl@aslmr-serv.med.ge.com (Carl Crawford) writes:
  64. >>>
  65. >>>consider the following program:
  66. >>>
  67. >>>main() {
  68. >>>    int i,j,ax;
  69. >>>    ax = 0;
  70. >>>    for(i=0;i<3;i++){
  71. >>>        j = ax * i;
  72. >>>        puts("in for loop");
  73. >>>    }
  74. >>>}
  75. >>>when compiled with cc (sun os 4.1 on sparc 1+), the 
  76. >>>code runs thru the loop three times. when comiled with 
  77. >>>the -O flag it only runs once. hom come the optimization 
  78. >>>screws up the loop?
  79. >
  80. >>Try upgrading your machine to either 4.1.1 or 4.1.2.  I ran
  81. >>your test program and did not see the problem with either 4.1.1
  82. >>or 4.1.2.
  83. >
  84. >No, the problem still exists in 4.1.2. I experienced exactly the same
  85. >behaviour as described above.
  86. >
  87. >
  88. >
  89. >--
  90. >----------------------------------------------------------------------------
  91. >Kristian Jorg, Software Design Support and Methods ! I speak for myself and
  92. >Ericsson Telecom AB, Karlstad, Sweden              ! Not for my company!
  93. >E-mail: etxkrjg@solsta.ericsson.se           !
  94.  
  95.  
  96.  
  97.