[Ffmpeg-devel] Still struggling with -fPIC and MMX asm-code
Michael Niedermayer
michaelni
Fri Jul 15 22:54:25 CEST 2005
Hi
On Friday 15 July 2005 22:10, Tobias Grimm wrote:
> Rich Felker schrieb:
> >Giving up PIC which is useless on x86.
>
> But the Debian-Policy requires -fPIC :-(
>
> Michael said, the original patch from the Debian maintainer was wrong -
> and he was right. But I shouldn't have tried to reinvent the wheel by
> trying to split the assembler blocks. The solution was much easier,
> because the patch from the Debian package was on the right track and
> just contained a small bug. The patch replaces one of the register
> operands (which is not available anymore because of -fPIC) by a memory
> operand and modifies the code to use a memory address instead of a
> register. The bug was simply, that eax was overwritten even though it's
> value still needed to be used for qmat[i] addressing. At least my
> modification works now (see below) and I have learned a little bit about
> assembler code in gcc and MMX instructions :-)
[...]
> +#if defined(PIC) && !defined(ARCH_X86_64)
> + "push %%"REG_a" \n\t"
> + "movl %2, %%"REG_a" \n\t"
> + "movq (%%"REG_a"), %%mm5 \n\t" // qmat[0]
> + "pop %%"REG_a" \n\t"
> +#else
> "movq (%2), %%mm5 \n\t" // qmat[0]
> +#endif
well, i dont want to ruin your good mood but this solution isnt safe either,
though its much better then before
the problem is that push and pop modify %%esp and gcc can and does sometimes
address memory operands through %%esp thats especially likely if the
addressed variable is on the stack and -fomit-frame-pointer is used
though strictly gcc could use esp even without these, ive never seen it
IMHO the correct solution is to use -fomit-frame-pointer which increases the
number of available registers by 1 if you dont want or cant do this there are
many things which might work and obviously you could rewrite or disable the
loop and use the c based one
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
with movl on the stack without changing %%esp
theres also the possibility of adding a int temp ... "+m"(temp) and store it
in that
[...]
--
Michael
More information about the ffmpeg-devel
mailing list