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: [Commited] Constant fold (x | 5) != 0


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


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