home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / sys / sgi / 13322 < prev    next >
Encoding:
Text File  |  1992-09-07  |  2.6 KB  |  78 lines

  1. Path: sparky!uunet!olivea!sgigate!odin!bananapc.csd.sgi.com!ciemo
  2. From: ciemo@bananapc.csd.sgi.com (Dave Ciemiewicz)
  3. Newsgroups: comp.sys.sgi
  4. Subject: Re: 3.10 Based C++/Fortran 77
  5. Message-ID: <1992Sep4.233001.6074@odin.corp.sgi.com>
  6. Date: 4 Sep 92 23:30:01 GMT
  7. References: <32258@adm.brl.mil> <p5aa664@twilight.wpd.sgi.com> <1992Sep2.171736.10178@spatial.com> <pdcguvk@twilight.wpd.sgi.com> <gregc.715642054@cgl.ucsf.edu>
  8. Sender: news@odin.corp.sgi.com (Net News)
  9. Organization: Silicon Graphics, Customer Support Division
  10. Lines: 65
  11. Nntp-Posting-Host: bananapc.csd.sgi.com
  12.  
  13. In article <gregc.715642054@cgl.ucsf.edu>, gregc@socrates.ucsf.edu (Greg Couch%CGL) writes:
  14. |> wsj@triton.wpd.sgi.com (Bill Johnson) writes:
  15. |> 
  16. |> >In general, you'll find the 3.10 compilers to be significantly more reliable
  17. |> >than the 2.20 compilers.  There is no easy way to run both simultaneously.
  18. |> >Mixing and matching 2.20 pieces with 3.10 pieces will not work, in general.
  19. |> 
  20. |> We have found the 3.10 optimizer (-O, -O2) to be less reliable than the
  21. |> 2.20 optimizer.  In particular, watch out for loops where the increment is
  22. |> done somewhere within the loop.  For example (bug already filed with customer
  23. |> support),
  24. |> 
  25. |>     result = 0;
  26. |>     len = strlen(s);
  27. |>     while (len > 0)
  28. |>         if (s[--len] == '*')
  29. |>             result = 1;
  30. |>     return result;
  31. |> 
  32. |> returns 1 even when the string doesn't have an asterix in it.
  33. |> 
  34. |> Unfortunately, we have inherited 10's of thousands of lines of code, that used
  35. |> to work, with the above idiom scattered everywhere.  And rather than examine
  36. |> each line, we now compile it -O1 with the consequential slower performance.
  37. |> 
  38.  
  39. There is a bug in the 3.10 optimizer with respect to doing loop unrolling.
  40. The following workaround should give you all of the benefits of -O2
  41. optimization while working around the loop unrolling bug. (It worked for
  42. me here when I tested it.)
  43.  
  44.      cc -O2 -Wo,-loopunroll,0 foo.c -o foo
  45.  
  46. ----- foo.c ------------------------------------------------------------------
  47. #include <stdio.h>
  48. #include <string.h>
  49.  
  50. int
  51. foo(const char* s)
  52. {
  53.         int result;
  54.         int len;
  55.         result = 0;
  56.         len = strlen(s);
  57.         while (len > 0)
  58.                 if (s[--len] == '*')
  59.                         result = 1;
  60.         return result;
  61. }
  62.  
  63. main()
  64. {
  65.         printf("Should be 1: %d\n", foo("*"));
  66.         printf("Should be 0: %d\n", foo(" "));
  67. }
  68. ----- foo.c ------------------------------------------------------------------
  69.  
  70.  
  71. -- 
  72.  
  73.     __   * __   _  __  ___            
  74.    /  \ / / /  / \/  \/   \     He was a man like any other man, however, not
  75.   /    /  \/  /  /\  /    /    quite like any other man.
  76.   \___/\__/\_/  /_/ / \__/    
  77.                *        
  78.