[Ffmpeg-devel] Still struggling with -fPIC and MMX asm-code

Tobias Grimm listaccount
Sat Jul 16 00:45:24 CEST 2005


Michael Niedermayer schrieb:

>well, i dont want to ruin your good mood but this solution isnt safe either, 
>  
>

Uhhh... here goes my free weekend :-)

>though its much better then before
>  
>

At least it works now :-)

>the problem is that push and pop modify %%esp and gcc can and does sometimes 
>address memory operands through %%esp 
>

Wasn't aware of this. Thanks for the hint!

>IMHO the correct solution is to use -fomit-frame-pointer which increases the 
>  
>

I try to avoid this to be able to debug ffmpeg, just in case I need to.

>if you want a quick solution and dont care that it will be slow as hell on 
>moderns cpus, try 2 xchgl %2, %%"REG_a" surrounding the movq or back it up 
>  
>

Your'e right xchgl seems to be damn slow - at least from what I found by
google. Maybe because it locks the CPU bus and interrupts?

>with movl on the stack without changing %%esp 
>

Do you mean this way?


#if defined(PIC) && !defined(ARCH_X86_64)
            "movl %%"REG_b", 4(%%esp)        \n\t" // "push" REG_b
without modifying %esp
            "movl %2, %%"REG_b"            \n\t"       
            "movq (%%"REG_b", %%"REG_a"), %%mm5    \n\t" // qmat[i]
            "movl 4(%%esp),  %%"REG_b"        \n\t" // "pop" REG_b
without modifying %esp        
#else
            "movq (%2, %%"REG_a"), %%mm5        \n\t" // qmat[i]
#endif


It works too. And if it's saver than using push/pop, this would be my
prefered solution.

>theres also the possibility of adding a int temp ... "+m"(temp) and store it 
>in that
>

Backing it up on the stack should be slightly faster, shouldn't it?

Tobias





More information about the ffmpeg-devel mailing list