Grant Edwards schrieb:

>>>     r = (uint32_t)u1 * (uint32_t)u2;

>> This will result in a 32x32 Bit Multiplication with the result
>> cropped to 32 Bits.
> 
> Which is identical to a 16x16 multiply with a 32 bit result.

The result is identical, but it strongly depends on the complier what
will be generated. It might be a 32x32=>64 bit multiplication and the 64
bit result is reduced to 32 bit. That is unnessecary overhead.


>> r = (uint32_t)u1 * u2;
> 
> GCC generates the exact same code (as it should).

O.k, then GCC is smart, but don't expect other compilers to show the
same behavior.


Ralf

Reply via email to