ECCO: Evidence-Driven Causal Reasoning for Compiler Optimization
Abstract
Compiler auto-tuning faces a dichotomy between traditional black-box search methods, which lack semantic guidance, and recent Large Language Model (LLM) approaches, which often suffer from superficial pattern matching and causal opacity. In this paper, we introduce ECCO, a framework that bridges interpretable reasoning with combinatorial search. We first propose a reverse engineering methodology to construct a Chain-of-Thought dataset, explicitly mapping static code features to verifiable performance evidence. This enables the model to learn the causal logic governing optimization decisions rather than merely imitating sequences. Leveraging this interpretable prior, we design a collaborative inference mechanism where the LLM functions as a strategist, defining optimization intents that dynamically guide the mutation operations of a genetic algorithm. Experimental results on seven datasets demonstrate that ECCO outperforms the LLVM opt -O3 baseline, achieving an average 24.44% reduction in cycles.
Lay Summary
Compilers are programs that translate human-written code into efficient machine instructions. Getting the fastest possible performance often requires carefully tuning many compiler settings—a task that traditional methods struggle with because they lack deep understanding, while modern AI approaches often act like "black boxes" that cannot explain their reasoning. We built ECCO, a framework that combines the reasoning ability of large language models with the exploration strength of evolutionary search. First, we teach the model to explain why certain code changes improve performance—for example, by linking specific patterns in the code to measurable speedups. Then, instead of blindly guessing optimizations, ECCO uses the model's explanations as a guide to intelligently explore better compiler flag combinations. On seven different benchmark suites, ECCO reduces program execution time by 24.44% on average compared to a strong standard compiler setting. More importantly, because ECCO provides human-readable reasoning, researchers and engineers can understand why an optimization works, building trust and enabling further improvements.