GCC Explorer - an interactive take on compilation
Posted May 24, 2012 20:27 UTC (Thu) by khim
In reply to: GCC Explorer - an interactive take on compilation
Parent article: GCC Explorer - an interactive take on compilation
But I still contend that if I ask the compiler to do -O3, then it should be able to apply the combined results of thousands of man-years of experience to generate better code than I could.
Sorry, but no. When human spends a week or month to generate code this is accepted. When compiler spends measly 1.5 hours people are becoming mightly antsy.
So, in this instance, why not have gcc inline the printf() function, and then optimise it.
Try to take a look on printf implementation one of these days. That's... quite an experience. Computed gotos and function pointers, bazillion tables and locales, I'm not sure even human can optimize it to a single string. No, I take it back: I know human can't do that because it's not possible. Output of %d depends on locale!
Compiler is clever beast, but there are limits for what it can do.
to post comments)