This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] PR opt/3995: Optimize (A&C)!=0 into A<0 (take 2)
- From: Roger Sayle <roger at eyesopen dot com>
- To: Richard Henderson <rth at redhat dot com>
- Cc: <gcc-patches at gcc dot gnu dot org>
- Date: Sun, 5 May 2002 15:20:33 -0600 (MDT)
- Subject: Re: [PATCH] PR opt/3995: Optimize (A&C)!=0 into A<0 (take 2)
On Sun, 5 May 2002, Richard Henderson wrote:
> On Sun, May 05, 2002 at 12:08:11PM -0600, Roger Sayle wrote:
> > + /* Handle extension from a narrower type. */
> > + if (TREE_CODE (exp) == NOP_EXPR
> > + && TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (exp, 0))) < width)
> > + return sign_bit_p (TREE_OPERAND (exp, 0), val);
>
> Now that sign_bit_p doesn't check for sign-ness, this recursion must.
I started with a patch that tested for signedness in the above recursion
but whilst it was bootstraping I realized that this wasn't required.
Even if A is a zero-extension from unsigned char to unsigned int, we
can still use a signed char comparison against 0x80. You'll notice
that the comment above the sign_bit_p was modified to mention that it
handles both zero and signed extension.
> > + void
> > + test5 (int i, int set)
> > + {
> > + if ((i & 0x80000000) == 0)
>
> int can be a 16-bit type. Need to check INT_MIN. In fact, you
> might as well just use the minima from limits.h rather than hard
> coding values.
I'll try and come up with a revised test.
Roger
--