[Ffmpeg-devel] [PATCH] (4) building with --disable-opts on i386

Marco Manfredini mldb
Mon Aug 14 19:08:50 CEST 2006


On Sunday 13 August 2006 21:52, Michael Niedermayer wrote:

> looks funny, but ive no strong objection against it if it works and isnt
> slower for recent gcc with optimizations on

I think I found a near optimal solution. I can create the neccesary copies of 
the parameters on the fly using statement expressions. Now I can put 
everything in a macro which I can compile-time switch. That way performance 
won't even degrade on older compilers.

#ifdef __OPTIMIZE__
#define FIX_ASM_INPUT_FOR_UNOPT(V) (V)
#define FIX_ASM_OUTPUT_FOR_UNOPT(V) (V)
#else
#define FIX_ASM_INPUT_FOR_UNOPT(V) (({typeof(V) tmp=(V); tmp;}))
#define FIX_ASM_OUTPUT_FOR_UNOPT(V) (*({typeof(V) *tmp=&(V); tmp;}))
#endif

Example: 

asm volatile(
   "movd       %0, %%mm0 \n\t"
   "movd       %2, %%mm1 \n\t"
   "punpckldq  %1, %%mm0 \n\t"
   "punpckldq  %3, %%mm1 \n\t"
   "movq    %%mm0, %%mm2 \n\t"
   "pfmul   %%mm1, %%mm0 \n\t"
   "pswapd  %%mm1, %%mm1 \n\t"
   "pfmul   %%mm1, %%mm2 \n\t"
   "pfpnacc %%mm2, %%mm0 \n\t"
   ::"g" FIX_ASM_INPUT_FOR_UNOPT(in2[-2*k]), "m"(in1[2*k]),
   "g" FIX_ASM_INPUT_FOR_UNOPT(tcos[k]), "m"(tsin[k])
   );

An offending parameter just needs FIX_ASM_INPUT_FOR_UNOPT prefixed. The only 
drawback is, that "m" constraints must be changed to "g" or similar, because 
gcc deprecates non-lvalues for the "m" constraint since 3.3 - This is why %0 
and %2 are fixed, movd also accepts registers as operands.

Fixing outputs doesn't require a change to the constraints: 
 :"=m" FIX_ASM_OUTPUT_FOR_UNOPT(output[2*k])
, "=m" FIX_ASM_OUTPUT_FOR_UNOPT(output[n2-2-2*k])

The next good thing is, that it should be fairly easy to merge the split asm 
blocks again (aka FIX_ASM_INPUT_FOR_GCC2AND3)

I need these macros at least in dsputil_mmx.c and fft_3dn2.c. Shall I prepare 
two patches for these or may I put the macros in a header file? 

Marco





More information about the ffmpeg-devel mailing list