Microsoft is developing an advanced code optimizer for its Visual C++ compiler back end to improve performance and code size.
Visual C++ is Microsoft's variant of the still-popular general-purpose systems programming language founded in 1979. Offered in an unsupported preview release this week, the code optimizer right now is mostly for testing purposes, said Microsoft's Gratian Lup, a software engineer in the company's compiler and language platform group.
Microsoft wants to enable more aggressive optimizations, including some that can leverage more compile-time information and modern compiler technologies, Lup said. "The design of some of the older optimization passes made it difficult to implement more advanced transformations and to make improvements at a faster pace," he said. "As the new framework was intended to be the basis of many future optimization efforts, a core design objective was to make it easier to implement, test and measure new optimizations."
When it comes to code types, Microsoft is improving both scalar and vector code. "There are many cases where both performance and code size can be improved, sometimes quite substantially. The framework attempts to solve several deficiencies of the old optimizer," said Lup.
With the current technology, the old expression optimizer has a small set of functions and a limited view of the function; it's also missing many small optimizations. "The new optimizer takes advantage of the Static Single Assignment form, which allows handling more complex expressions, that potentially span the entire function," Lup said. "Another advantage of the SSA form is that it makes it possible to write simpler and more efficient algorithms, eliminating the need of using more complicated and slower techniques such as data-flow analysis."
The project also enables easy development with less potential for mistakes, offering better static analysis of code and emphasizing testing and correctness. "Given the large scope of the project, ensuring and maintaining correctness was a top priority," said Lup. "This was achieved by using formal verification, testing with randomly-generated programs (fuzz testing) and popular programs and libraries, such as Chrome, Firefox, CoreCLR, and Chakra."
Lup is advising developers to build and test applications with the new optimizer and report any problems. He pledged there would be more improvements forthcoming; optimizations likely for the next Visual Studio release include improvements for Boolean expressions, merging of similar branches and bit estimator enhancements.
Compiler bits with the new optimizer are accessible by installing the most recent VisualCppTools package using NuGet. The official release of the optimizer is planned for Visual Studio 2015 Update 3. Microsoft would not comment on when this would be available; Update 2 was released in late-March.