[ Thread Index | 
Date Index
| More lists.liballeg.org/allegro-developers Archives
] 
Eric Botcazou wrote:
I simply wonder whether it wouldn't be better (performance-wise) to let the
FPU do the multiplication instead of using the integer-based fixmul().
Bob, are you around there ? What do you think of the game i386 FPU's fmul()
vs algcc386.h's fixmul() ?
I have to agree, fixmul needs some optimizing, if only to remove all 
those branches. I'll see if I can come up something.
Using the FPU to do integer math is generally a bad idea:
 - Float<->int conversion requires a memory access (slow)
 - Converting the read float to a fractional part will require a 
division (slower)
 - Floats have less precision then ints. We'd need to use doubles, for 
which division is even slower.
 - The result then needs to be checked for overflow and clamped to 
(float)0x7FFFFFFF (slowest)
 - The result needs to be converted back to an int (slow).
 - We get a long dependency chain involving the FPU (very slow)
All in all, I think we should keep fixmul as integer ops.