[Bug tree-optimization/58736] IVOPTs rewrites unsigned to signed arith, exposing undefined overflow

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Oct 15 11:37:00 GMT 2013


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

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
rewrite_use_compare rewrites

  b.1_5 = (unsigned int) b.0_20;
  _6 = 2147483647 - b.1_5;
  _7 = (int) _6;
  _9 = _7 < pretmp_23;

into

  _13 = 2147483647 - b.0_20;
  _9 = _13 < pretmp_23;

here:

  /* The induction variable elimination failed; just express the original
     giv.  */
  comp = get_computation (data->current_loop, use, cand);

using the candidate b.0_20 where already the affine form of the
computation is wrong:

{
  type = int
  offset = 2147483647
  elements = {
    [0] = b.0_20 * -1
  }
}

which is because the use induction variable for _7 is wrongly determined by
simple_iv as { 2147483643, +, 1 } (but it has ->no_overflow == false but
nothing in IVOPTs ever checks that which looks like a bug).



More information about the Gcc-bugs mailing list