by uticus · 3y ago · 0 comments
> Peephole optimisations, idioms | Idioms
From the software side, what is it exactly that makes it so difficult to write a higher-level language that must be optimized, instead of a language that already exposes the optimizations in a friendly way?
("higher-level language" meaning c, not python or something)
Difficulty increases as the source and target languages become less similar, as more ambitious performance optimisations are attempted, as more comprehensive type/lint/warning style systems are implemented and as performance constraints on the compiler itself tighten.
So a compiler that takes imprecise scribblings, spots errors in them, and emits asymptotically perfect machine code for heterogenous distributed systems in real time is quite dramatically more complicated than cat.
Are your asking why we could not expose optimization feature (e.g. branch hint to replace branch-prediction) in the programming language ?
Are you asking if it's difficult for a compiler to optimize some type of high-level languages ?
Since "higher-level" language is C in your question, what the "language that already exposes the optimizations in a friendly way" ? Are you thinking the CPU µop as a language ?