|
|
|
|
|
by refulgentis
522 days ago
|
|
I'm not quite sure what you're visualizing for compilers, if I understand correctly, what I'd say is: tl;dr: there are general optimizations for "this function in a for loop is a constant expression, we dont need to call it 500 times" or "this obscure combination of asm instructions is optimal on pentium iii 350 mhz dual core" not "we need to turn this unholy CS101 student spaghetti code where they do a 500 branch-if into a for loop" comment over here is attempting to communicate that as well https://news.ycombinator.com/item?id=42705758 I've never, ever, heard the idea that compilers are burdened by the workload of maintaining thousands of type-specific optimizations for hilariously bad code, until today. I've been here since 2009, so it is puzzling to me to see it referred to off hand, in a "this is water" manner https://en.wikipedia.org/wiki/This_Is_Water |
|
I've heard tons of people complain about slow compilers, so even if compiler devs find it easy architect their compilers to do multiple kinds of optimisations there's a cost to it that devs running the compilers pay.
Also, if you think about it, optimising code has to follow diminishing returns, so at some point we are putting too much CPU time into little to no gains, and it's also possible to get slower code with more optimisations if they interact poorly, or at least not better code even if spending more CPU time. This is why there's -O3 in gcc and it's not the default, there's a cost to it that's likely not worth paying.