https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79721

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2017-02-27
                 CC|                            |rguenth at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
SCCP currently guards doing everything in unsigned arithmetic with

      /* If def's type has undefined overflow and there were folded
         casts, rewrite all stmts added for def into arithmetics
         with defined overflow behavior.  */
      if (folded_casts && ANY_INTEGRAL_TYPE_P (TREE_TYPE (def))
          && TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (def)))
        {

but here folded_casts is false.  Clearly the above is bogus as it doesn't take
into account that computing the final value replacement involves association.
So the "fix" would be to unconditionally rewrite the expression to use unsigned
arithmetic (even for ! TYPE_OVERFLOW_UNDEFINED, which should have been
TYPE_OVERFLOW_WRAPS anyway).

Reply via email to