This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
RE: [PATCH, i386]: Optimization of the i386 and x86_64 compilers
- From: "Meissner, Michael" <michael dot meissner at amd dot com>
- To: "Jan Hubicka" <hubicka at ucw dot cz>, "Uros Bizjak" <ubizjak at gmail dot com>
- Cc: "GCC Patches" <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 2 Mar 2007 12:54:26 -0500
- Subject: 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.