This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: A gcc-cris bug?



On Oct 6, 2004, at 7:45 AM, Dave Korn wrote:


#include <stdio.h>
int foo=100;

int f ()
{
  foo = 0;
}

void main ()
{
  int i;

  for (i = 0; i < foo; i++)
    {
      f ();
    }
  printf("foo is: %d, i is: %d\n",foo,i);
}

But the mainline at -O3 produces great code aka no loops at all: ;; Function main (main)

main ()
{
  int i;
  int foo.0;

<bb 0>:
  foo.0 = foo;
  if (foo.0 > 0) goto <L0>; else goto <L7>;

<L7>:;
  i = 0;
  goto <bb 2> (<L2>);

<L0>:;
  foo = 0;
  i = 1;
  foo.0 = 0;

<L2>:;
  printf (&"foo is: %d, i is: %d\n"[0], foo.0, i) [tail call];
  return;

}

Thanks,
Andrew Pinski


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]