PATCH: Remove SLOW_BYTE_ACCESS from get_best_mode
H. J. Lu
hjl@lucon.org
Thu Sep 14 16:43:00 GMT 2006
On Thu, Sep 14, 2006 at 07:04:02AM -0700, H. J. Lu wrote:
> On Wed, Sep 13, 2006 at 11:26:36PM -0700, H. J. Lu wrote:
> > On Wed, Sep 13, 2006 at 06:03:28PM -0700, H. J. Lu wrote:
> > > On Thu, Sep 14, 2006 at 12:20:31AM +0100, Paul Brook wrote:
> > > > > Here is the updated patch. I ran a micro benchmark with code difference
> > > > > similar to twolf:
> > > > >
> > > > > - movl (%rdi), %eax
> > > > > - xorb %ah, %ah
> > > > > - subl $1, %eax
>
> This is a partial register stall. There is a 60% penalty on Core 2.
> I updated my patch only not to do it for -Os.
>
> > > > > + movq (%rdi), %rax
> > > > > + andl $4294902015, %eax
> > > > > + subq $1, %rax
> > > > > jne .L8
> > > > >
> > > > > There is no speed difference on Nocona. I checked my SPEC results.
> > > > > twolf isn't very stable on my Nocona.
> > > >
> > > > The former is significantly smaller though (7 bytes vs. 12 bytes).
> > > >
> > >
> >
> > In general, widen mode of access to a full word is good. But x86-64 is
> > a special case due to bigger code size of DImode. This updated patch
> > won't widen SImode.
> >
> > BTW, I didn't update SLOW_BYTE_ACCESS document since I am not clear
> > what it is supposed to do.
> >
> >
>
> Here is an updated patch.
>
Here is a case where SImode/DImode is 1-10% slower than QImode:
union bitfield {
struct {
unsigned int field0 : 1;
unsigned int field1 : 2;
unsigned int field2 : 2;
unsigned int field3 : 1;
long foo;
} bitfields, bits;
unsigned int u32All;
signed int i32All;
float f32All;
};
int
fooo (program* prog, unsigned int i,
unsigned int x, unsigned int y, unsigned int z)
{
prog->array[i].bitfields.field1 = ((x > y) ? ((x > z) ? 0 : 2) : ((y
> z) ? 1
: 2));
switch (prog->array[i].bitfields.field1)
{
case 0:
return 3;
case 1:
return 5;
case 2:
return 9;
default:
break;
}
return 10;
}
In this case, we are examing the bitfield. Basically, SImode/DImode
will require less memory access if more than one fields are accessed.
But QImode may be faster if we need to check the field value.
H.J.
More information about the Gcc-patches
mailing list