Linked by Thom Holwerda on Mon 29th Jun 2009 20:47 UTC
Thread beginning with comment 370803
To view parent comment, click here.
To read all comments associated with this story, please click here.
To view parent comment, click here.
To read all comments associated with this story, please click here.





Member since:
2006-01-02
While I agree with what you're saying about the people who use high-level languages and stupidly complex algorithms, you get no points for using inline assembly. With modern, competent compilers (e.g. gcc, msvc, sun studio, etc), the compiler will likely choose a good code sequence to balance size and speed. Especially if you give it some feedback in the form of profile-guided optimization. Inline asm sometimes inhibits the compiler's optimizer and generally is a waste of time if you're good enough to write clear, straightforward-to-optimize C code without too many pointers flying about (to avoid aliasing deoptimizations).
The real trick lies in writing straightforward, maintainable code for the bulk of your program so that the compiler will do a good job, and then tweaking the C code (or using processor intrinsics where there's a not-normally-generated instruction that will help you out) to get the instruction output you want from the compiler. Chances are good that you'll get it with a modern compiler, even if you don't resort to stupid tricks with the >>, XOR, or AND operators or manually strength-reducing divisions.