[Bug tree-optimization/63665] [5 Regression] wrong code with signed overflow even with -fwrapv

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Oct 28 09:43:00 GMT 2014


--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
To better bisect this also use -fno-tree-copy-prop (which otherwise hides
this on the 4.9 branch for example).

It's forwprop that does the bogus transform on

  y_5 = -2147483648;
  _6 = y_5 + -2147483648;

which ends up calling fold_binary (NE_EXPR, y_5 + -2147483648, 0) which
computes it as 1.

8769          tree new_const = int_const_binop (reverse_op, const2, const1);

results in -2147483648(OVF) even though we have -fwrapv in effect which
the triggers

      /* If the constant operation overflowed this can be
         simplified as a comparison against INT_MAX/INT_MIN.  */
      if (TREE_OVERFLOW (new_const))

without changing how we compute TREE_OVERFLOW it seems that this test needs
to be guarded with !TYPE_OVERFLOW_WRAPS ().

More information about the Gcc-bugs mailing list