• Welcome to Dark Bit Factory & Gravity.
 

Optimising FPU?

Started by Stonemonkey, August 10, 2006

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Stonemonkey

Anyone know much about doing this, I have this piece of code (with several other pieces almost identical) that I think could be improved. There are 2 values already in the fpu stack.


    fld dword ptr[eax]
    fld st
    fsub dword ptr[ebx]
    fmul st(2)
    fst dword ptr[ecx+28]
    fmul st(3)
    faddp st(1)
    fstp dword ptr[ecx+4]
   
    fld dword ptr[eax+4]
    fld st
    fsub dword ptr[ebx+4]
    fmul st(2)
    fst dword ptr[ecx+24]
    fmul st(3)
    faddp st(1)
    fstp dword ptr[ecx]


Any help appreciated, Cheers.

Fryer.

Jim

Not much you can do with it.

Things you can try:
avoid storing/using the result of the mul until the latest possible moment - the mul will overlap with other independent instructions if it can.
interleave 2 or more calculations to achieve that.
look at a bigger bit of code to optimise
look at SSE2

Jim
Challenge Trophies Won:

Stonemonkey

OK thanks Jim, I was wondering if there was any way to interleave the 2 pieces of code somehow using something like fxch so that it wouldn't be waiting for each instruction to finish before it could get on with the next one.

Jim

Yes, you'd use fxch to do it, to get the mul result somewhere else in the stack so you can use st0 for more calculations, but it's only mul, div and the other trig/transcendental functions you'd do that for.  Not for adds, subs, loads and stores.

Jim
Challenge Trophies Won: