CompilerDream is a model-based reinforcement learning approach designed for general code optimization in compilers.
Optimization in compilers is crucial for computer and software engineering success.
The effectiveness of optimizations relies on the selection and ordering of optimization passes applied to the code.
Current methods for finding the optimal sequence of optimization passes are either slow or struggle to generalize to unseen code.
CompilerDream introduces a compiler world model that simulates optimization passes and an agent trained on this model for generating effective optimization strategies.
By training on a large-scale program dataset, CompilerDream can serve as a general code optimizer for various application scenarios and source-code languages.
CompilerDream showcases strong optimization capabilities for autotuning and outperforms LLVM's built-in optimizations, leading the CompilerGym leaderboard.
The model's ability to generalize across diverse datasets without prior training surpasses state-of-the-art methods in both value prediction and end-to-end code optimization.