This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix bitfield-- != 0 transformation in fold-const.c


!    /* This optimization is invalid for ordered comparisons
!       if CONST+INCR overflows or if foo+incr might overflow.
!       This optimization is invalid for floating point due to rounding.
!       For pointer types we assume overflow doesn't happen.  */
!    && (POINTER_TYPE_P (TREE_TYPE (arg0))
!        || (INTEGRAL_TYPE_P (TREE_TYPE (arg0))
!     && (code == EQ_EXPR || code == NE_EXPR))))

What about checking for unsignedness or -fwrapv here?  Something like

(POINTER_TYPE_P (TREE_TYPE (arg0))
  || (INTEGRAL_TYPE_P (TREE_TYPE (arg0))
      && (code == EQ_EXPR || code == NE_EXPR ||
               flag_wrapv || TREE_UNSIGNED (TREE_TYPE (arg0))))

Paolo




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]