Mail Archives: djgpp/2009/05/27/00:01:19
Hi again,
On May 26, 12:39=A0am, Andris Pavenis <andris DOT pave DOT DOT DOT AT iki DOT fi> wrote:
>
> >> Perhaps the best source is the documentation (archives
> >> present at specified URL even if not montioned in earlier post) or gcc=
-help
> >> mailing list if the information is not found in documentation.
>
> > Yes, I know. I tried (and tried and tried ...). What I discovered is
> > that "__attribute__((optimize(2)))" works on function prototypes
> > (only) ...
>
> If there is no help from the documentation then You can ask in gcc-help
> mailing list (search archives at first:http://gcc.gnu.org/lists.html).
>
> I myself usually avoid using constructions specific to GCC only even if
> I do not use different compilers.
More searching didn't really turn up anything, but here's the (old
old) June '08 patch for quick glance if you're curious:
http://gcc.gnu.org/ml/gcc-patches/2008-06/msg01435.html
So here's some more interesting info. Does the function attribute
work? Yes. I #ifdef'd around it just to be sure. As you can see,
there's an obvious speed difference, so something is getting
optimized! Good, proof it works! :-) But I also noticed the .EXE
size was bigger than my build yesterday for no obvious reason. It
seems the "optimize" attribute is adding 30k to the code size!! I
suspect this is a bug since I can't imagine needing to store any extra
info (even if LD did optimize for COFF, which I don't think it does,
only ELF).
EDIT: Unofficial MinGW 4.4.0 doesn't have this problem (actually,
its .EXE is < 1k smaller instead of bigger).
P.S. Using "-O3" on the cmdline always overrides "O2" in the pragma
(which is only bad because it's slower with -O3 here ... oh well).
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
#ifndef SLOW
#if GCC_VERSION >=3D 40400 // see CPP.INFO for the GCC_VERSION
define
#define FUNC_OPTIMIZE __attribute__((__optimize__("O2")))
int dot_product_noasm(short *t, short *w, int n) FUNC_OPTIMIZE ;
void train_noasm(short *t, short *w, int n, int err) FUNC_OPTIMIZE ;
#endif
#endif
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
-----------------------------------------------------
[ Vista/DJGPP ] - Tue 05/26/2009 >gmake paq8o8z CXXFLAGS=3D"-DNOASM -s -
DSLOW" &
paq8o8z doydoy *.cpp & v *.exe & del paq8o8z paq8o8z.exe
gpp -DNOASM -s -DSLOW paq8o8z.cpp -o paq8o8z
paq8o8z compiled May 26 2009 by DJGPP 2.04 / G++ 4.4.0 for FreeDOS
514187264 bytes DPMI available
Creating archive doydoy.paq8o8z via level 1 with 1 file(s)...
paq8o8z.cpp 152203 -> 36049
152203 -> 36083
Time 27.86 sec, used 37286742 bytes of memory
-rwxr-xr-x 1 Rugxulo root 656896 May 26 22:06 paq8o8z.exe
[ Vista/DJGPP ] - Tue 05/26/2009 >gmake paq8o8z CXXFLAGS=3D"-DNOASM -s"
&
paq8o8z doydoy *.cpp & v *.exe & del paq8o8z paq8o8z.exe
gpp -DNOASM -s paq8o8z.cpp -o paq8o8z
paq8o8z compiled May 26 2009 by DJGPP 2.04 / G++ 4.4.0 for FreeDOS
518434816 bytes DPMI available
Creating archive doydoy.paq8o8z via level 1 with 1 file(s)...
paq8o8z.cpp 152203 -> 36049
152203 -> 36083
Time 15.77 sec, used 37286742 bytes of memory
-rwxr-xr-x 1 Rugxulo root 686592 May 26 22:08 paq8o8z.exe
[ Vista/DJGPP ] - Tue 05/26/2009 >echo Notice the 30k size difference!
Notice the 30k size difference!
-----------------------------------------------------
Hope this helps in some way!
- Raw text -