GCC 4.0 pragma interface/implementation regression with templates
Hello, The attached implementation/header issues a warning when $ gcc-4.0-c -o test_undefined.o test_undefined.cpp undefined_constructor.hpp:13: warning: inline function 'Base::Base()' used but never defined This does not happen with 3.x compilers. If you remove the #pragma interface, the warning disapears. It does also not happen if you write #pragma implementation "undefined_constructor.hpp" in the cpp file. It apears to be triggered when using a template class with a base class. I had similar warnings for a missing destructor. Peter Soetens #pragma interface struct Base { }; template< class T> struct Sub : public Base { Sub() {} }; #pragma implementation #include "undefined_constructor.hpp" void foo() { Sub sub; }
GCC 3.3.5: -march=i586 does not use all pentium FPU instructions
I was wondering why the above gcc parameter does not enable the use of the fst/fld opcodes for pentium processors, while -march=i686 does. The Intel manuals specifically say that they can be used across all pentium processors. Example : $ gcc -g -c -mcpu=i586 mdouble.cpp -o mdouble.o $ objdump -dS -M intel mdouble.o <...> void foo() { 0: 55 push ebp 1: 89 e5 movebp,esp 3: 83 ec 10subesp,0x10 double d; double a; d = 3.0; 6: b8 00 00 00 00 moveax,0x0 b: ba 00 00 08 40 movedx,0x4008 10: 89 45 f8movDWORD PTR [ebp-8],eax 13: 89 55 fcmovDWORD PTR [ebp-4],edx a = d; 16: 8b 45 f8moveax,DWORD PTR [ebp-8] 19: 8b 55 fcmovedx,DWORD PTR [ebp-4] 1c: 89 45 f0movDWORD PTR [ebp-16],eax 1f: 89 55 f4movDWORD PTR [ebp-12],edx } 22: c9 leave 23: c3 ret While : $ gcc -g -c -mcpu=i686 mdouble.cpp -o mdouble.o $ objdump -dS -M intel mdouble.o <...> void foo() { 0: 55 push ebp 1: 89 e5 movebp,esp 3: 83 ec 10subesp,0x10 double d; double a; d = 3.0; 6: dd 05 00 00 00 00 fldds:0x0 c: dd 5d f8fstp QWORD PTR [ebp-8] a = d; f: dd 45 f8fldQWORD PTR [ebp-8] 12: dd 5d f0fstp QWORD PTR [ebp-16] } 15: c9 leave 16: c3 ret FLD and FSTP are available on all pentium processors. Is there a chance, for other reasons, that my code will not run on a pentium if I use -march=i686 ? Thanks for any help on this, Peter -- ---- Peter Soetens, Research Assistant http://www.orocos.org Katholieke Universiteit Leuven Division Production Engineering, tel. +32 16 322773 Machine Design and Automation fax. +32 16 322987 Celestijnenlaan 300B [EMAIL PROTECTED] B-3001 Leuven Belgium http://www.mech.kuleuven.ac.be/pma
Re: GCC 3.3.5: -march=i586 does not use all pentium FPU instructions
Hi Samuel, On Friday 11 February 2005 16:38, you wrote: > I think Intel's confusing numbering system has confused > you. All ix86 processors, if the expression > x in first ix86 < x in second ix86 > holds true, then second ix86 is compatible. The i586 is > NOT the Pentium. Nor is the i686. But the i686 was one of > the first Intel processors with built-in FPU. If you are > asking for Pentium, try the following switches: > -march=pentium > -march=pentium -mmmx # Pentium MMX > -march=pentium2 > -march=pentium3 > -march=celron > -march=pentium4 > -march=prescott # this will probably get you in trouble > > If you use any of these switches, it will add FP > instruction calls. -march=prescott has caused more than > one problem elsewhere. This is what the GCC manual says, I added the '***'s -mcpu=cpu-type Tune to cpu-type everything applicable about the generated code, except for the ABI and the set of available instructions. The choices for cpu-type are i386, i486, i586, i686, pentium, pentium-mmx, pentiumpro, pentium2, pentium3, pentium4, prescott, nocona, k6, k6-2, k6-3, athlon, athlon-tbird, athlon-4, athlon-xp, athlon-mp, winchip-c6, winchip2 and c3. While picking a specific cpu-type will schedule things appropriately for that particular chip, the compiler will not generate any code that does not run on the i386 without the -march=cpu-type option being used. ***i586 is equivalent to pentium and i686 is equivalent to pentiumpro***. k6 and athlon are the AMD chips as opposed to the Intel ones. -march=cpu-type Generate instructions for the machine type cpu-type. The choices for cpu-type are the same as for -mcpu. Moreover, specifying -march=cpu-type implies -mcpu=cpu-type. My experiments with setting options confirms the ***'d part, wrt the FPU opcodes being used : i586, pentium and pentium-mmx generate the same (non fpu-using) code, while i686 and pentiumpro generate the fpu-using code. Any other hints ? Peter PS : please CC me since I'm not on the list. Thank you. > > Samuel Lauber > > > I was wondering why the above gcc parameter does not enable the use of > > the fst/fld opcodes for pentium processors, while -march=i686 does. The > > Intel manuals specifically say that they can be used across all pentium > > processors. > > > > Example : > > $ gcc -g -c -mcpu=i586 mdouble.cpp -o mdouble.o > > $ objdump -dS -M intel mdouble.o > > <...> > > void foo() > > { > > 0: 55 push ebp > > 1: 89 e5 movebp,esp > > 3: 83 ec 10subesp,0x10 > > double d; > > double a; > > d = 3.0; > > 6: b8 00 00 00 00 moveax,0x0 > > b: ba 00 00 08 40 movedx,0x4008 > >10: 89 45 f8movDWORD PTR [ebp-8],eax > >13: 89 55 fcmovDWORD PTR [ebp-4],edx > > a = d; > >16: 8b 45 f8moveax,DWORD PTR [ebp-8] > >19: 8b 55 fcmovedx,DWORD PTR [ebp-4] > >1c: 89 45 f0movDWORD PTR [ebp-16],eax > >1f: 89 55 f4movDWORD PTR [ebp-12],edx > > } > >22: c9 leave > >23: c3 ret > > > > While : > > $ gcc -g -c -mcpu=i686 mdouble.cpp -o mdouble.o > > $ objdump -dS -M intel mdouble.o > > <...> > > void foo() > > { > > 0: 55 push ebp > > 1: 89 e5 movebp,esp > > 3: 83 ec 10subesp,0x10 > > double d; > > double a; > > d = 3.0; > > 6: dd 05 00 00 00 00 fldds:0x0 > > c: dd 5d f8fstp QWORD PTR [ebp-8] > > a = d; > > f: dd 45 f8fldQWORD PTR [ebp-8] > >12: dd 5d f0 fstp QWORD PTR [ebp-16] > > } > >15: c9 leave > >16: c3 ret > > > > FLD and FSTP are available on all pentium processors. > > Is there a chance, for other reasons, that my code will not run on a > > pentium if I use -march=i686 ? -- Peter Soetens, Research Assistant http://www.orocos.org Katholieke Universiteit Leuven Division Production Engineering, tel. +32 16 322773 Machine Design and Automation fax. +32 16 322987 Celestijnenlaan 300B [EMAIL PROTECTED] B-3001 Leuven Belgium http://www.mech.kuleuven.ac.be/pma
Re: GCC 3.3.5: -march=i586 does not use all pentium FPU instructions
Thank you for the very clarifying text below. Some version of it would surely be helpful in the gcc manual when introducing the -march and -mcpu/-mtune flags. Since I needed atomic read/writes of FP variables in a multi-threaded program, I have no other option than using the slow fld/fst instructions, which is still many times faster than locking/unlocking a mutex. Peter On Saturday 12 February 2005 11:42, Marcel Cox wrote: > Peter Soetens wrote: > > I was wondering why the above gcc parameter does not enable the use > > of the fst/fld opcodes for pentium processors, while -march=i686 > > does. The Intel manuals specifically say that they can be used across > > all pentium processors. > > There are 2 options to tell the compiler about your wanted processor. > The -march=xyz option tells you the instruction set to use, while the > -mcpu=xyz option tells you for which processor the program should run > fastest. > If you supply the -march option, but not the -mcpu option, then the > compiler will assume you use the same processor for both. > > The difference in the code you see are actually due to the -mcpu > option. For your first code example, you implicitly use -mcpu=586 and > for the second example, you use -mcpu=686. So your first code is > supposed to run fastest on a Pentium class processor while your second > code is supposed to run fastest on a Pentium2 class processor. > Now, an a Pentium processor, the FLD and FST instructions are > (relatively) expensive. So the compiler decides it is faster to do > load/store operations using integer registers. On Pentium2 class > processors, the FLD and FST instructions are much faster, and now the > compiler considers it worthwhile to use them. > > Now if you want to generate code that will be guaranteed to run on > Pentium processors, but runs best on Pentium2 class processors, you > have to use both the options -march=pentium and -mcpu=pentium2 (you can > also use 586 and 686 which are aliases, but I would recommend you to > use real processor names) > Of course, as Pentium2 processors are not so common any more either, > you can also tune your code for Pentium4 using -mcpu=pentium4, or for > AMD Athlon processors using -mcpu=athlon or some specific athlon model. > > Note that on newer versions of GCC (starting with 3.4.0), the -mcpu > option has been deprecated and replaced by the -mtune option to be > consistent with other processor architectures supported by GCC. -- Peter Soetens, Research Assistant http://www.orocos.org Katholieke Universiteit Leuven Division Production Engineering, tel. +32 16 322773 Machine Design and Automation fax. +32 16 322987 Celestijnenlaan 300B [EMAIL PROTECTED] B-3001 Leuven Belgium http://www.mech.kuleuven.ac.be/pma