Hi Everyone,
Dumb question - do the "tricks" on Paul Hsieh's web site "Integer multiplying by constants" http://www.azillionmonkeys.com/qed/amultl2.html work with imul or just mul?
Greg
They're tricks for multiplying by a constant - instead of using multiplies.
But they're unsigned, so they're substitutes mul. imul requires copying the sign-bit, which none those appear to do.
Greg,
It has got a bit more complicated than it used to be. On later hardware LEA is slow and bit shifts are slow as well but for multiplying by a constant it is still probably faster than using MUL or IMUL. Now Tedd has mentioned an obvious thing which you must consider as well and you may just be able to use NEG and/or ADD to fix it.