[fpc-pascal] fast integer multiplication

Marcel Martin mm10 at ellipsa.net
Fri Jul 29 11:36:30 CEST 2005


Peter Vreman a écrit :
 >Marcel Martin wrote :
>>Since you ask the question, I suppose you cannot simply
>>suppress the "movl $0,%edx" line generation [*]. What about
>>using a compiler directive, something like {$EXTENDEDMUL ON/OFF}
>>for instance?
> 
> 
> I don't like this. This means we have to add directives for all kind of
> special cpu features to improve some special corner cases.

But it is a special case because FPC makes it special. As I wrote
yesterday, when you write Word := Byte * Byte, what you get is
the exact result (not the result mod 2^8), when you write
Longword := Word * Word, what you get is the exact result (not the
Result mod 2^16), but when you write QWord := Longword * Longword,
there, what you get is not (always) the exact result but the result
mod 2^32. This is FPC which makes special this case by setting the
product high part to 0 (what it doesn't do with other cases).

Being said that, I agree with you that adding compiler directives
is not a good thing [*]. Here, it would be sufficient to suppress
the generation of the line "movl $0,%edx". Since you do not do so,
I suppose there would be some side effects I don't see at the
moment, but it would be the simplest solution.

[*] If QWord := Longword * Longword gave the exact result, it would
allow me to suppress a lot of compiler directives :-)

MM




More information about the fpc-pascal mailing list