Subject: Re: CVS commit: src/sys/arch/sgimips
To: None <cgd@broadcom.com>
From: Andrey Petrov <petrov@netbsd.org>
List: port-mips
Date: 10/08/2003 13:30:11
On Wed, Oct 08, 2003 at 12:49:27PM -0700, cgd@broadcom.com wrote:
> At Wed, 8 Oct 2003 19:31:12 +0000 (UTC), "Andrey Petrov" wrote:
> > I used 3.3.1 and this example is all right on sparc64 too.
> > here is my test
> >
> > int test2(int *p)
> > {
> >
> > if (((*p >> 16) & 0xffff) == 123)
> > return 1;
> >
> > return 2;
> > }
> > [ ... ]
> > Interesting that gcc indeed does access it as a halfword but still wants
> > to apply mask. It certainly looks like gcc optimizes this, just not
> > always successfully. Seems that I got to take back my performance argument:-)
>
> it accessed it as a signed halfword. if you change your source to:
>
> int test2(int *p)
> {
>
> if ((unsigned short)((*p >> 16) & 0xffff) == 123)
> return 1;
>
> return 2;
> }
>
Yeah, it's signedness, I just changed argument
int test2(unsigned int *p)
and got it optimised
lduh [%o0], %g1
cmp %g1, 123
mov 1, %o0
retl
movne %icc, 2, %o0
Quite cool, I should take back my gcc blame.
Andrey