Re:Does a compiler use all x86 instructions? (2010)
by column on Thursday August 25, 2016 @04:40AM
(#12357637)
is there any point in multiplying by 1 ?
[ Parent
| on HN ]
Re:Does a compiler use all x86 instructions? (2010)
by noselasd on Thursday August 25, 2016 @04:49AM
(#12357672)
It might be used to avoid a conditional.
Re:Does a compiler use all x86 instructions? (2010)
by column on Thursday August 25, 2016 @11:52AM
(#12360015)
Thank you for your answer but frankly I don't understand it. Could you please elaborate?
Re:Does a compiler use all x86 instructions? (2010)
by noselasd on Friday August 26, 2016 @10:37AM
(#12366566)
Generally multiplying with 1 can be used to just do (the equivalent in assembly of):
a = a * b;
instead of if (b != 1)
a = a * b;
Which is normally a win, as branching are expensive vs multiplication.