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

Christoph Lampert xvid-devel@xvid.org
Fri, 24 Jan 2003 14:36:25 +0100 (CET)


On Fri, 24 Jan 2003, Radek Czyz wrote:
> if (x) { // 50% incorrect prediction
>   x = ABS(x) // ~40% incorrect prediction
> ...
> ... and the same for y.

Where the heck in the code is this line??? 

> 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?

Possibly yes. 


> 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%...

Easy: Remove the if completely :-) 

x = ABS(x)   has just the same effect and should be faster, especially if
we modify the ABS macro to not be   (x>0):(x):(-x) 
but something without a branch  (is there a bit-logic expression for
ABS? for MMX there's this saturation trick...). At least it should become
some conditional move instruction on i686 and higher.

> 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...

??? 

I never had problem with CodeAnalyst to run complete XviD (was an older
version, but nevertheless...) Maybe you can switch off some options?

gruel