Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Interacting with a compiler sounds horrible. Think of the questions it might need to ask: "Hey! I could use AVX2 instructions here, after I inline a bunch of stuff and eliminate some dead code, but it requires doing a bunch of memory copying. Is that a good idea?". How would you answer a question like that?

And then, since optimizations are target dependent, you would need to go through this exercise for each target. Sounds fun.



I would imagine it would be more things like "This function would optimize so much better if I could assume that the two parameters don't alias. Should I add that restriction to the function's type signature?"


Maybe it would be more productive to make a new language more amenable to optimization rather than trying to clumsily bolt it onto C. It's not like C is a good language, anyway. I find FORTRAN more pleasant in many ways, and that's not quite the state of the art...


How you'd answer depends very much on what you're doing -- which is the point of asking. You might be able to remove the memory copying by fiddling with alignment somewhere in calling code and adding an annotation saying you did that. Bam, problem solved. Or you might not be able to do that, in which case it would still be nice to know what tradeoffs you're making.


But consider, for it to be worth asking, it's got to be something that's very difficult to infer, or the compiler wouldn't need to ask. That means it will probably be difficult for you to infer as well.

In practice, you might have to profile all possible options, which would quickly turn into a major project if you're asked more than a handful of questions.

And, of course, even if you can figure it out, that alignment annotation you just made is only optimal on the one target. Even on x86 it will depend on what instructions are available.


If you can identify and apply these decisions, why can't the compiler?

Everything about this seems to be saying, "We're stagnant with our current compiler/optimization paradigm...screw it."




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: