x86 failure on loop reversal

Joern Rennecke amylaar@cygnus.co.uk
Fri Apr 3 21:52:00 GMT 1998


The appended tests fails for egcs at -O2.  This is a synthetic test to
demonstrate a bug I found while looking for some possible improvements
to check_dbra_loop: when the initial value is normalized, an overflow
can occur.
I suggest that if we did a normalisation that results in a negative initial
value, we change the comparison into an unsigned one.
Actually, we could do this change always when we erverse the loop, and then
we could do away with the NONNEG note.  However, changing a signed compare
into an unsigned compare might fail sometimes (depending on how well we
can grok the RTL and what the target accepts), so it is better not to have
to rely on this.

int
f()
{
  int j = 1;
  int i;
  for (i = -0x80000000; i < 0x60000000; i += 0x10000000) j <<= 1;
  return j;
}

int
main ()
{
  if (f () != 16384)
    abort ();
  return 0;
}



More information about the Gcc mailing list