[PATCH] Fix bitfield-- != 0 transformation in fold-const.c
Paolo Bonzini
bonzini@gnu.org
Sat Mar 6 23:20:00 GMT 2004
> > (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
More information about the Gcc-patches
mailing list