home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!olivea!sgigate!odin!bananapc.csd.sgi.com!ciemo
- From: ciemo@bananapc.csd.sgi.com (Dave Ciemiewicz)
- Newsgroups: comp.sys.sgi
- Subject: Re: 3.10 Based C++/Fortran 77
- Message-ID: <1992Sep4.233001.6074@odin.corp.sgi.com>
- Date: 4 Sep 92 23:30:01 GMT
- 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>
- Sender: news@odin.corp.sgi.com (Net News)
- Organization: Silicon Graphics, Customer Support Division
- Lines: 65
- Nntp-Posting-Host: bananapc.csd.sgi.com
-
- In article <gregc.715642054@cgl.ucsf.edu>, gregc@socrates.ucsf.edu (Greg Couch%CGL) writes:
- |> wsj@triton.wpd.sgi.com (Bill Johnson) writes:
- |>
- |> >In general, you'll find the 3.10 compilers to be significantly more reliable
- |> >than the 2.20 compilers. There is no easy way to run both simultaneously.
- |> >Mixing and matching 2.20 pieces with 3.10 pieces will not work, in general.
- |>
- |> We have found the 3.10 optimizer (-O, -O2) to be less reliable than the
- |> 2.20 optimizer. In particular, watch out for loops where the increment is
- |> done somewhere within the loop. For example (bug already filed with customer
- |> support),
- |>
- |> result = 0;
- |> len = strlen(s);
- |> while (len > 0)
- |> if (s[--len] == '*')
- |> result = 1;
- |> return result;
- |>
- |> returns 1 even when the string doesn't have an asterix in it.
- |>
- |> Unfortunately, we have inherited 10's of thousands of lines of code, that used
- |> to work, with the above idiom scattered everywhere. And rather than examine
- |> each line, we now compile it -O1 with the consequential slower performance.
- |>
-
- There is a bug in the 3.10 optimizer with respect to doing loop unrolling.
- The following workaround should give you all of the benefits of -O2
- optimization while working around the loop unrolling bug. (It worked for
- me here when I tested it.)
-
- cc -O2 -Wo,-loopunroll,0 foo.c -o foo
-
- ----- foo.c ------------------------------------------------------------------
- #include <stdio.h>
- #include <string.h>
-
- int
- foo(const char* s)
- {
- int result;
- int len;
- result = 0;
- len = strlen(s);
- while (len > 0)
- if (s[--len] == '*')
- result = 1;
- return result;
- }
-
- main()
- {
- printf("Should be 1: %d\n", foo("*"));
- printf("Should be 0: %d\n", foo(" "));
- }
- ----- foo.c ------------------------------------------------------------------
-
-
- --
-
- __ * __ _ __ ___
- / \ / / / / \/ \/ \ He was a man like any other man, however, not
- / / \/ / /\ / / quite like any other man.
- \___/\__/\_/ /_/ / \__/
- *
-