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 12:30:56
On Wed, Oct 08, 2003 at 11:51:43AM -0700, cgd@broadcom.com wrote:
> At Wed, 8 Oct 2003 18:38:21 +0000 (UTC), "Andrey Petrov" wrote:
> > We use gcc, and even though I tried on sparc64 I'd be surprised if mips port
> > does better with this regard. I also would argue because of driver which is used
> > for all ports.
>
> GCC 3.2.3 seems to do OK on MIPS. (the local mods we've made to it
> wouldn't change this behaviour.)
>
> I'd expect 3.3.1 and later to do similarly well, but haven't checked.
>
>
>
> cgd
> --
> 16 [ldt-sj3-010] xx % cat /tmp/x.c
>
> unsigned char foo(int *x)
> {
> return ((x[1] >> 8) & 0xff);
> }
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;
}
.file "t2.c"
.section ".text"
.align 4
.global test2
.type test2, #function
.proc 04
test2:
!#PROLOGUE# 0
!#PROLOGUE# 1
sethi %hi(64512), %g1
ldsh [%o0], %g2
or %g1, 1023, %g1
mov 1, %o0
and %g2, %g1, %g2
cmp %g2, 123
retl
movne %icc, 2, %o0
.size test2, .-test2
.ident "GCC: (GNU) 3.3.1"
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:-)
Andrey