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



--- Comment #15 from Zdenek Dvorak <rakdver at gcc dot gnu.org> 2012-12-11 
18:19:40 UTC ---

Created attachment 28928

  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28928

A proposed patch



This patch fixes the error (and also makes the code more clearly match what is

described in the comments).  Long story: we try to avoid rewriting computations

that define bivs, as that is usually unnecessary.  However, there is a special

case where rewriting is still needed; e.g.,



loop

{

  tmp = biv + 1;

  use (tmp);

  biv = tmp + 1;   (*)

}



Ivopts may decide to eliminate the temporary variable tmp by expressing its use

in some other way (based on a different biv, etc.).  So, if we did not rewrite

(*), it would refer to a variable that is no longer defined.



And in this case, we used a wrong way of expressing the biv computation that

may cause signed overflows.  The patch makes us instead to fall back to the

general rewriting case, which does not have this problem.  Untested (beyond the

single testcase + C-only bootstrap).

Reply via email to