optimization/5269: loop unroller fails to pull the right number of copies out

dalej@apple.com dalej@apple.com
Thu Jan 3 15:16:00 GMT 2002


>Number:         5269
>Category:       optimization
>Synopsis:       loop unroller fails to pull the right number of copies out
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jan 03 15:16:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     dale johannesen
>Release:        gcc version 3.1 20011229 (experimental)
>Organization:
>Environment:
ppc Darwin (but probably doesn't matter)
>Description:
The following program will abort when compiled with          -O2 -funroll-loops.   This is because the loop in "foo"
is unrolled incorrectly.  It is unrolled 4 times and
executed 49 times, for 196 stores, plus there is 1 extra store before the loop.  This is not enough; there should be 3  stores pulled out of the loop.

int a[200];
int foo() {
  int i;
  for (i=198; i>=0; i--)
    a[i] = i;
  a[199] = 199;
}
main() {
  int i;
  foo();
  for ( i=0; i<199; i++ )
    if ( a[i]!=i )
      abort();
}
>How-To-Repeat:
gcc -O2 -funroll-loops
a.out
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-bugs mailing list