This is the mail archive of the egcs@egcs.cygnus.com mailing list for the EGCS project. See the EGCS home page for more information.


[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index] [Subject Index] [Author Index] [Thread Index]

bug in loop optimization with -Os (-O2)




I have founded gcc/egcs bug while compile and run test file
testsuit/gcc.c-torture/execute/loop-2c.c:
------------------------------------------------
int a[2];

__inline__ f (b, o)
{
  unsigned int i;
  int *p;
  for (p = &a[b], i = b; --i < ~0; )  /* this is a problem place */
    *--p = i * 3 + o;                 /* this is a problem place */
}

g(int b)
{
  f (b, (int)a);
}

main ()
{
  a[0] = a[1] = 0;
  g (2);
  if (a[0] != (int)a || a[1] != (int)a + 3)
    abort ();
  exit (0);
}
--------------------------------------------------------
I have compiled this test with -O2 (gcc 2.7.2.3) or
-Os (egcs 1.1.1 and egcs 1.1.2pre1). In both case this test aborts
after start. I'm look to debugging output (-da). Bug was borne in loop
optimization pass.
This test normally runs with -O,-O3,-O9 options.

Denis.

PS: originally I have founded this bug in my ATMEL AVR port with
egcs-1.1.2pre.