Will modern (2008/2010) incantations of Visual Studio or Visual C++ Express produce x86 MUL instructions (unsigned multiply) in the compiled code? I cannot seem to find or
My intuition tells me that the compiler chose IMUL
arbitrarily (or whichever was faster of the two) since the bits will be the same whether it uses unsigned MUL
or signed IMUL
. Any 32-bit integer multiplication will be 64-bits spanning two registers, EDX:EAX
. The overflow goes into EDX
which is essentially ignored since we only care about the 32-bit result in EAX
. Using IMUL
will sign-extend into EDX
as necessary but again, we don't care since we're only interested in the 32-bit result.