This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH] Fix bitfield-- != 0 transformation in fold-const.c
- From: "Paolo Bonzini" <bonzini at gnu dot org>
- To: "Roger Sayle" <roger at eyesopen dot com>
- Cc: <gcc-patches at gcc dot gnu dot org>
- Date: Sun, 7 Mar 2004 00:19:32 +0100
- Subject: Re: [PATCH] Fix bitfield-- != 0 transformation in fold-const.c
- References: <Pine.LNX.email@example.com>
> > (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.