This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: [PATCH, i386]: Optimization of the i386 and x86_64 compilers


> -----Original Message-----
> From: gcc-patches-owner@gcc.gnu.org
[mailto:gcc-patches-owner@gcc.gnu.org]
> On Behalf Of Jan Hubicka
> Sent: Friday, March 02, 2007 7:03 AM
> To: Uros Bizjak
> Cc: GCC Patches
> Subject: Re: [PATCH, i386]: Optimization of the i386 and x86_64
compilers
> 
> > Hello!
> >
> > Attached patch implements the idea, proposed by Michael Meissner in
PR
> > 31019. The core of his idea is to substitute (1 << ix86_[tune|arch])
> > in x86_some_var & (1 << ix86_[tune|arch])) by a precalculated global
> > variable.
> >
> > The results of this patch are quite suprising as the text size of
cc1
> > on i686 host was lowered considerably:
> >
> > size cc1
> >   text    data     bss     dec     hex filename
> > 7632793   18876  574516 8226185  7d8589 cc1
> >
> > size cc1-patched
> >   text    data     bss     dec     hex filename
> > 6731749   18876  574516 7325141  6fc5d5 cc1-patched
> >
> > Yes, for 901k.
> 
> Neat :)  It also imply that our insn-attrtab/insn-recog is truly ugly
> piece of autogenerated code, but this is very nice win.
> 
> I wonder if we are able to fold something like
> (((1 << var) & 0x2) || ((1 << var) & 0x4)) into (1<<var) & 0x6
> as we can do for var & 0x2 || var & 0x4 since the former is how a lot
of
> code looks like.

One win I've thought about is to optimize multiple comparisons against
small constants, ie:

	If (a == 5 || a == 7 || a == 11) { ... }

Into:

	if (((unsigned)a) < 32 && (1 << a) & ((1 << 5) | (1 << 7) | (1
<< 11)) 

Then you would also want to handle switch statements where you have a
few cases that are small constants to using this also.

The trouble is you can't optimize away the test if the value is 0..31
normally, but perhaps the gen* functions can do that.




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]