This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Commited] Constant fold (x | 5) != 0
- From: "Joseph S. Myers" <jsm at polyomino dot org dot uk>
- To: Roger Sayle <roger at eyesopen dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Tue, 23 Mar 2004 19:50:43 +0000 (UTC)
- Subject: Re: [Commited] Constant fold (x | 5) != 0
- References: <Pine.LNX.4.44.0403231054150.16603-100000@www.eyesopen.com>
On Tue, 23 Mar 2004, Roger Sayle wrote:
> [1] The expression "A & B" is nonnegative, if A or B is nonnegative.
> [2] The expression "A | B" is nonnegative, if A and B are nonnegative.
> [3] The expression "A | B" is nonzero, if A is nonzero or B is nonzero.
It should be possible to write testcases for these, using the tree-level
warnings that depend on whether something is known to be nonnegative.
For example,
int
f(unsigned short a1, unsigned short a2, unsigned int b)
{
return ((a1+a2)|5) > b ? 2 : 3;
}
should no longer warn with -Wsign-compare.
--
Joseph S. Myers
jsm@polyomino.org.uk