[Bug tree-optimization/25985] [4.2 Regression] with optimization integer math fails

rakdver at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Thu Mar 16 03:15:00 GMT 2006



------- Comment #6 from rakdver at gcc dot gnu dot org  2006-03-16 03:15 -------
Actually, my previous comment is wrong, it is ivcanon (more precisely, # of
iterations analysis).  Consider this testcase:

#include <stdio.h>

void bla(int x)
{
  if (x < -100)
   exit (0);
}

int main(void)
{
  int bits = 25;
  while (bits) {
      printf ("%d\n", bits);
      bla(bits);
      bits -= 8;
  }
  return 0;
}

We note that bits is signed, therefore it cannot overflow, and conclude the
loop must be finite.  Using this assumption, we conclude it iterates two times.
However, this would only be correct if the loop were exited through this
particular exit, as these examples demonstrate.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25985



More information about the Gcc-bugs mailing list