Andrew Gaffney <[EMAIL PROTECTED]> writes:
> Stroller wrote:
>> On 29 Sep 2003, at 12:10 pm, Ulrich Rhein wrote:

>>> gcc doesn't use SIMD instructions (except in very rare cases), because
>>> it is hard for a compiler to use them. Additionally, gcc doesn't
>>> generate much faster (just bigger) code when compiling with -march=...,
>>> if it does generate different code at all. There is usually no
>>> significiant performance gain with it.
>> Why is Gentoo's ability to set CFLAGS optimisations in make.conf so
>> widely touted, then..?
> I was under the impression that it depended on what the application
> actually does. Any programs that do any kind of video or multimedia
> can typically be greatly speeded up by a -mmmx or -m3dnow which would
> be included by default for any -march=xxx where the processor supports
> it.

Have you benchmarked it? And looked at the code gcc generates?

MMX, 3Dnow!, and SSE(2) are all SIMD extensions. That means that the
processor does the same operations on multiple data. MMX, for instance,
has 64 Bit registers (%mm[0-7]) and instruction which operate with these
registers. The idea behind it is that you have two 32 Bit values, four
16 Bit values or eight 8 Bit values on which you perform the same
operation simultanously. That means that a 'paddd %mm0, %mm1' adds the
two 32 Bit values in %mm0 to the two in %mm1 (paddw does with the 16 Bit
values and paddb with the 8 Bit values respectively). 3Dnow! operates on
the same registers, but adds support for single precision floating point
numbers. SSE is the same stuff on 128 Bit registers (%xmm[0-7]).

If you want to make use of those SIMD operations, you usually need

1) the data structures in a suitable format. gcc can not do this for
   you, as it would interfere with the ABI.
2) an algorithm which can be split up in a way that you can make use of
   these instructions. Note that this code needs to have as few
   conditional jumps as possible.
3) You usually need to write different code for this
   case, and for a compiler, this is *very* hard.

If you want to make use of SIMD instructions, you usually have to
handwrite it yourself. mplayer includes such handwritten assembler code,
for instance.

Uli
-- 
"Or have we eaten on the insane root,
 that takes the reason prisoner?"  -- MacBeth I, 3


--
[EMAIL PROTECTED] mailing list

Reply via email to