NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: gcc, march and sse



On Wed, Dec 03, 2008 at 04:26:11PM +0100, Joel Carnat wrote:
> Hello,
> 
> I read that Slackware Linux compiles most of its packages with
> "-march=i486 -mtune=i686". As far as I understood gcc's manpage, this
> means "keep code compatible with 486 CPU but allow the use pentiumpro
> special features", right ?

No.  It produces binaries using the instruction set from the i486 with a
scheduling optimised for the i686.  The way CPUs work, the order in
which you feed it the instructions matters a lot.

> Still from the man page, MMX is supported since "pentium2 (or pentium-mmx
> only)", SSE since "pentium3", SSE2 since "pentium-m", SSE3 since
> "prescott".
> 
> I tweaked my mk.conf to compile pkgsrc (on a domU) using "-O2 -march=486
> -mtune=686" but I'm now wondering if any on those compiled programs will
> use MMX or SSE when running on my laptop or intel-based servers (intel
> core2duo).

They won't.  When you use -march, gcc will produce code that can run on
that architecture.

> Then second question, in case the previous thought is correct, if I use
> "-march=i486 -mtune=nocona", is there a way to see which instruction the
> program uses ? For example, if I compile xorg/firefox/mplayer and then run
> it in a special manner, can I see that the core2duo uses MMX/SSE*
> instruction while the C3 only use MMX instruction (from the same binary) ?

Those applications use assembly (either external or inline) to achieve
that.  It's not gcc's choice.

-- 
Quentin Garnier - cube%cubidou.net@localhost - cube%NetBSD.org@localhost
"See the look on my face from staying too long in one place
[...] every time the morning breaks I know I'm closer to falling"
KT Tunstall, Saving My Face, Drastic Fantastic, 2007.

Attachment: pgpsJGOHllXWB.pgp
Description: PGP signature



Home | Main Index | Thread Index | Old Index