3 ms·
This is a great example of something compilers definitely do better than humans writing assembly. Inlining code, especially with multiple passes, is something
by dahart 10y ago
This is a great example of something compilers definitely do better than humans writing assembly.
Inlining code, especially with multiple passes, is something humans don't do. I still modularize in assembly and write functions, factor code used in multiple places into a single spot. The compiler is free to expand the same function inline a thousand places, and then use the expanded code to collapse to fewer instructions.
The flattening can definitely be cool to see. So in your example, what would you have done if you'd written the assembly yourself? Do you feel like the compiler did something you wouldn't have?
- JoeAltmaier 10y agoMany programmers would have declared the object, set its members, and written main to fetch and return the data member. Not unreasonable, since humans tend to write abstractions pretty much as they're stated.