Yes, the fun in compilers: Even if every phase and every optimization actually produces optimal results, the combination is probably not optimal.
One deep problem is that there is no good optimization goal. Today's CPUs are too complex and unpredictable performance-wise.
Another problem is: Register pressure is one of the most important things to minimize, but how can the phases before register allocation do that? They use a surrogate, like virtual registers, and thus become heuristics even if they solve their theoretical problem optimally.
One deep problem is that there is no good optimization goal. Today's CPUs are too complex and unpredictable performance-wise.
Another problem is: Register pressure is one of the most important things to minimize, but how can the phases before register allocation do that? They use a surrogate, like virtual registers, and thus become heuristics even if they solve their theoretical problem optimally.