home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.sgi
- Path: sparky!uunet!haven.umd.edu!darwin.sura.net!mips!odin!bananapc.csd.sgi.com!ciemo
- From: ciemo@bananapc.csd.sgi.com (Dave Ciemiewicz)
- Subject: Re: Optimization problem with 3.1 compilers
- Message-ID: <1992Aug25.183256.3342@odin.corp.sgi.com>
- Sender: news@odin.corp.sgi.com (Net News)
- Nntp-Posting-Host: bananapc.csd.sgi.com
- Organization: Silicon Graphics, Customer Support Division
- References: <1992Aug19.000616.8590@leland.Stanford.EDU>
- Date: Tue, 25 Aug 1992 18:32:56 GMT
- Lines: 47
-
- In article <1992Aug19.000616.8590@leland.Stanford.EDU>, dhinds@leland.Stanford.EDU (David Hinds) writes:
- |> I have a program that compiles and executes reliably with the MIPS 2.1
- |> compilers under Irix 4.0.1, but core dumps with a segmentation violation
- |> when a particular function is compiled at -O2 or above with the 3.1
- |> compilers and Irix 4.0.5A. Here is a short example with the problem:
- |>
- |> > #include <stdio.h>
- |> > #define MAXP 12
- |> >
- |> > void main(void)
- |> > {
- |> > int *i, *j, step[MAXP+1], k;
- |> > double sum;
- |> > float all2[MAXP+1];
- |> >
- |> > for (k = 0; k < MAXP+1; k++) {
- |> > step[k] = k; all2[k] = 2.0;
- |> > }
- |> >
- |> > sum = 0.0; k = 2;
- |> > for (i = &step[2]; i <= &step[MAXP]; i++, k++) {
- |> > printf("k = %d\n", k);
- |> > for (j = &step[1]; j != i; j++)
- |> > sum += all2[*j] - 1;
- |> > }
- |> > printf("Sum = %f\n", sum);
- |> > }
- |>
- |> When I compile this with 'cc -O2 bug.c' and run a.out, I get:
- |>
- |> > k = 2
- |> > k = 3
- |> > k = 4
- |> > k = 5
- |> > k = 6
- |> > Segmentation fault (core dumped)
- |>
-
- I don't know if you got a response on this or not. The problem is a bug
- in the 3.10 version of /usr/lib/uopt which incorrectly unrolls the inner
- loop "for (j = ...". There is a bug submitted on this problem.
-
- To work around this problem, turn off loop unrolling in uopt (see uopt(1)
- man page):
-
- cc -O2 -Wo,-loopunroll,0 bug.c -o bug.c
-
-