On Sat, Jan 23, 2010 at 6:33 PM, Steve White <swh...@aip.de> wrote:
> Hi, Andrew!
>
> Thanks for the suggestion, but it didn't make any difference for me.
> Neither the speed nor the assembler was significantly altered.
>
> Which version of gcc did you use?  Mine is 4.4.1.
>
> I threw everything at it:
>        gcc -std=c99 -Wall -pedantic -O3 -ffast-math -mmmx -msse -msse2 
> -mfpmath=sse -mtune=pentium-m -o dt dt.c -lm -lc
> I should say, I have tried a lot of other combinations.
> I have never got gcc to perform well with this test.  You will also
> see that I thought of alignment, and tried to correct for that.
>
> Nevermind icc for the moment, with whatever trick it may be doing.
> Why is the SSE2 division so slow, compared to multiplication?
>
> Change one character in the division test to make a multiplication test.
> It is an order of magnitude difference in speed.

It's because multiplication latency is like 4 cycles while division is about
20, also one mutliplication can be issued per cycle while only every
17th instruction can be a division (AMD Fam10 values).

GCC performs loop interchange with -ftree-loop-linear but the pass
is scheduled in an unfortunate place so no further optimization happens.

Richard.

> Try it yourself!
>
> Thanks!
>
> On 23.01.10, Andrew Pinski wrote:
>> On Sat, Jan 23, 2010 at 8:47 AM, Steve White <swh...@aip.de> wrote:
>> > gcc has this (gcc -std=c99 -O3 -msse2 -mfpmath=sse -lm -S dt.c)
>> > icc has this (icc -Wall -w2 -fast -c dt.c)
>>
>> icc's -fast is equivalent to gcc's -ffast-math option which you did
>> not supply so you comparing apples to oranges.
>>
>> Note supplying -ffast-math will have gcc to pull out the division out
>> of the loop which should speed up your program with some loss of
>> precision.
>>
>> Thanks,
>> Andrew Pinski
>>
>
> --
> | -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
> | Steve White                                             +49(331)7499-202
> | e-Science / AstroGrid-D                                   Zi. 35  Bg. 20
> | -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
> | Astrophysikalisches Institut Potsdam (AIP)
> | An der Sternwarte 16, D-14482 Potsdam
> |
> | Vorstand: Prof. Dr. Matthias Steinmetz, Peter A. Stolz
> |
> | Stiftung privaten Rechts, Stiftungsverzeichnis Brandenburg: III/7-71-026
> | -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
>

Reply via email to