This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix combiner issues with shifts (PR c/37924)
On Mon, Oct 27, 2008 at 05:13:20PM -0400, Michael Meissner wrote:
> However, your test code should declare a to be
> signed char instead of char, since there are platforms where chars are unsigned
> by default.
I'm aware of that, that's why I've tested the testcase works with both
-fsigned-char and -funsigned-char. I wanted to cover both signed char
(on some arches) and unsigned char (on others).
> > --- gcc/testsuite/gcc.c-torture/execute/pr37924.c.jj 2008-10-27 19:24:11.000000000 +0100
> > +++ gcc/testsuite/gcc.c-torture/execute/pr37924.c 2008-10-27 19:23:10.000000000 +0100
> > @@ -0,0 +1,29 @@
> > +/* PR c/37924 */
> > +
> > +extern void abort (void);
> > +
> > +char a;
> > +
> > +int
> > +test (void)
> > +{
> > + int b = -1;
> > + return ((unsigned int) (a ^ b)) >> 9;
> > +}
> > +
> > +int
> > +main (void)
> > +{
> > + if (test () != (-1U >> 9))
> > + abort ();
> > + a = 0x40;
> > + if (test () != (-1U >> 9))
> > + abort ();
> > + a = 0x80;
> > + if (test () != (a < 0) ? 0 : (-1U >> 9))
> > + abort ();
> > + a = 0xff;
> > + if (test () != (a < 0) ? 0 : (-1U >> 9))
> > + abort ();
> > + return 0;
> > +}
Jakub