[XviD-devel] Don't do " signed /= unsigned "
Marco Al
xvid-devel@xvid.org
Sat, 11 Jan 2003 15:40:49 +0100
Radek Czyz wrote:
> I think that division is faster than if - am I correct?
The old version probably compiled to a DIV too for division by 2 for negative
numbers, I dont think compilers will use tricks for division by 2 of signed
integers, although with a good compiler it probably used a CMOV instead of a
conditional branch ... so the if wouldnt hurt much.
With GCC or ICC the old version would probably only take a couple cycles more
than yours.
> sure that some kind of bitshift would be even faster... do you know a
> way to make it a bitshift, but dividing negative values correctly?
After a couple of tries :
(dx >> qpel) + (dx & qpel & (dx >> (sizeoff(dx) * 8 - 1)))
Can be executed in 4-5 cycles, versus 17 for DIV.