Choosing the best multiplication

Paolo Bonzini bonzini@gnu.org
Fri Sep 24 22:46:00 GMT 2010


On 09/24/2010 10:10 AM, Paulo J. Matos wrote:
> The rules currently take the shape:
> ,----
> | (define_expand "umulqihi3"
> `----
>
> These rules were created in gcc42 and the idea was that we can use smult
> instead of umult whenever RAH (MSW of the result) is not used
> afterwards. The 2nd argument of make_mulqihi3 determines if we emit an
> smult instead of an umult.

You can use mul<mode>3 for non-widening multiplication, which would 
always use smult, and {u,}mul<mode1><mode2>3 for widening multiplication 
which has to use smult or umult for correctness.  That's how i386 
chooses between multi-operand imul (non-widening), single-operand imul 
(widening signed) and single-operand mul (widening unsigned).  Note that 
the i386 ISA lacks a non-widening unsigned multiplication exactly 
because it's pointless.

Or are you already doing that?

Paolo



More information about the Gcc mailing list