freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Devel] Question about optimizing FT_MulFix.


From: Toby J Sargeant
Subject: Re: [Devel] Question about optimizing FT_MulFix.
Date: Mon, 30 Apr 2001 18:01:35 +1000
User-agent: Mutt/1.1.9i

On Sun, Apr 29, 2001 at 08:31:05PM -0400, Tom Kacvinsky wrote:
> I don't understand the use of adding 0x8000, and the sign changing.

The adding of 0x8000 is to round to nearest, rather than round down (or
in this case, towards zero), which is likely to give better accuracy.

> Moreover, we avoid the two comparisons, the addition of 0x8000, and
> the multiplication by s.  This has to be worth *some* optimization.

I can't comment on the sign games, but I think that the reason for doing
this is to reduce overflow errors, by using an unsigned multiply for the
main part of the calculation. I would like to believe that a sensible C
compiler would translate the multiply into a conditional branch and
negate if that was going to be faster (given that the domain of s is
only 2 integers).

On most new hardware it's quite possible that a branch misprediction
is more costly than a multiply. On old hardware, the branch is almost
certainly better.

Toby.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]