Re[4]: [XviD-devel] Quality optimization

Radek Czyz xvid-devel@xvid.org
Fri, 24 Jan 2003 21:48:05 +1030


Hello,

Christoph wrote

> Yes. MMX has an instruction for that, other CPU ASMs might as well.
> If not, prefetch using C is possible, too. There are also other basic
> operations which always should be tried before immediately going to ASM:

> http://cdrom.amd.com/devconn/events/gdc_2002_amd.pdf

Thanks for that. It looks very useful, even though I wasn't able to
get any improvement yet.

Instead, I looked a bit deeper into code optimization techniques and
tools. I downloaded AMD's CodeAnalyst and run some motion estimation
tests.
I have some questions about it.
First thing I noticed: if CodeAnalyst is correct, branch prediction is
horrible. In particular in d_mv_bits() there is:

if (x) { // 50% incorrect prediction
  x = ABS(x) // ~40% incorrect prediction
...
... and the same for y.

I have 2 questions now.
CodeAnalyst requires the library to be built in debug mode, with no
optimization. If these results are true, that means that unoptimized
library is wrong - I don't care. Does it actually mean (with
reasonable probablity) that optimized library has the same problem?

And 2. How can I improve branch prediction? In this particular example
I have a hint for the compiler: it is _not_ zero. Usually. This hint
has better chances to be true than 50%...

Do you know better tools to do this stuff? CodeAnalyst ignores asm-ed
code, doesn't allow me to run some functions several times (don't ask
for details, 300MB needed for a single call of SearchP is a hint here)
and so on...

Best Regards,
Radek