News for hackers. Stuff that matters.
Re:Three hundred programming interviews in thirty days by foldr on Tuesday June 23, 2015 @08:10PM (#9768713)
In fact GCC will virtually always produce optimal code for multiplication by a constant. Targetting AVR, for example (which doesn't always have hardware multiply), GCC produces more compact code if you use '*' than if you use '<<'. Similarly, any attempt I made to multiply by non-round constants using bitshifting and addition led to less compact code.
Re:Three hundred programming interviews in thirty days by nitrogen on Sunday June 28, 2015 @04:42AM (#9792896)
The one case so far where I've seen better results using tricks like reciprocal multiplication and shifts was when there was no way for gcc to know it could throw away almost half of the bits due to input range limits. It would be kind of nice to have, say, a 19-bit integer type.
Re:Three hundred programming interviews in thirty days by mycelin on Wednesday June 24, 2015 @04:07AM (#9770278)
Uh, extremely unexpected.
Re:Three hundred programming interviews in thirty days by raverbashing on Wednesday June 24, 2015 @06:46AM (#9770745)
Not really, simplifying simple operations (like multiply by a constant) is pretty much Compilers 101 / Dragon Book kind of stuff