Re:Branch-free FizzBuzz in Assembly
by eckzow on Saturday January 03, 2015 @06:28PM
(#8832472)
By my reading that implementation was assembled by humans, not the optimizer.
Although, there's certainly nothing magical that prevents the optimizer from generating such code. Here's something[1] I just threw together that (ab)uses constexpr to do just that.
Re:Branch-free FizzBuzz in Assembly
by jevinskie on Saturday January 03, 2015 @07:32PM
(#8832661)
This code snippet really made my night. I never thought of using constexpr to write a FizzBuzz that compiles to one of the most "optimal" solutions that I have ever seen. Awesome!
Although, there's certainly nothing magical that prevents the optimizer from generating such code. Here's something[1] I just threw together that (ab)uses constexpr to do just that.
On my machine, building with:
Gives code similar to: Of course, having now written this I feel like I should retroactively fail my last interview.[1] https://gist.github.com/anonymous/7818f902a374a953b274