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


> > (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))))
>
> Unfortunately not.  This transformation is not valid for the other
> ordering operations, such as LT_EXPR, GE_EXPR etc...

Sorry, what I actually meant is

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

That is, allow for code != EQ_EXPR or NE_EXPR for signed types if the overflow
semantics are not defined.

> Consider the following counter example, for unsigned short x,
> "x-- > 0" is not equivalent to "--x > 65535".  Notice that this
> transformation only works for equality and inequality.

But you can convert for signed short x, x-- > -32768 to --x > 32767, because
overflow semantics are not defined.

Paolo




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