Pattern-Driven Evaluation of LLM Code Optimization: Isolating Compiler-Transcendent Semantic Reasoning
Organizations: Georgia Institute of Technology · University of Virginia
Abstract
Existing evaluations of LLM-based code optimization primarily measure end-to-end speedup, obscuring whether a model actually performs the intended optimization. For compiled languages, this is especially problematic: observed gains may reflect transformations already recoverable by modern optimizing compilers rather than optimization behavior attributable to the model itself. We present PatternBench, a benchmark for studying compiler-transcendent optimization, i.e., performance improvements that remain after aggressive compiler optimization. PatternBench targets residual optimization opportunities across seven classes of transformations and pairs runtime evaluation with an AST-based optimization faithfulness analysis that verifies whether the intended optimization is realized in the generated program. Experiments with frontier, open-weight, and fine-tuned models show that runtime speedup alone provides an incomplete account of optimization capability. Optimization faithfulness is strongly associated with realized speedup, and fine-tuning improves both faithfulness and optimization effectiveness. These results suggest that evaluation of LLM-based code optimization should measure not only performance outcomes, but also whether the target transformation was successfully executed.
Figures & tables
| Category | Total | Description |
|---|---|---|
| Semantic Redundancy (SR) | 112 | Remove redundant computation the compiler cannot hoist |
| Input-Sensitive (IS) | 96 | Specialize for runtime input distributions |
| Algorithmic (AL) | 78 | Replace with lower-complexity algorithms |
| Memory/IO (MI) | 77 | Improve memory access patterns and locality |
| Data-Structure (DS) | 76 | Change data representation or layout |
| Human-Style (HR) | 75 | Recover a fast form obscured by code structure |
| Model | SR | IS | CF | DS | AL | MI | HR | COMP |
|---|---|---|---|---|---|---|---|---|
| claude-opus-4-7 | 90 | 71 | 69 | 51 | 69 | 62 | 87 | 68 |
| gemini-3.5-flash | 83 | 74 | 71 | 46 | 55 | 62 | 88 | 65 |
| claude-sonnet-4-6 | 86 | 74 | 75 | 51 | 68 | 61 | 84 | 60 |
| minimax-m3 | 82 | 75 | 71 | 41 | 72 | 62 | 73 | 58 |
| glm-5 | 86 | 72 | 85 | 41 | 67 | 62 | 88 | 53 |
| qwen3-32b | 51 | 72 | 71 | 37 | 72 | 62 | 69 | 53 |
Appendix figures & tables2 assets
Supplementary material from the paper’s appendix.
Appendix
| Model | Equivalent (%) | Faithful (%) | Speedup ( ) | Expert (%) |
|---|---|---|---|---|
| claude-opus-4-7 | 90 | 70 | 17.2 | 34 |
| gemini-3.5-flash | 90 | 67 | 20.3 | 46 |
| claude-sonnet-4-6 | 90 | 65 | 17.6 | 31 |
| gemini-3-pro | 86 | 63 | 20.2 | 38 |
| minimax-m3 | 85 | 63 | 17.9 | 30 |
| glm-5 | 84 | 62 | 18.0 | 38 |
| Model | N | committed% | CWD (strict/AST) | CWD (LLM proxy) | |
|---|---|---|---|---|---|
| gemini-2.5-pro | 548 | 96.3 | 32.5% | 23.5% | 0.04 |
| gemini-2.5-flash | 545 | 95.8 | 33.9% | 21.1% | 0.07 |
| gemini-3-flash | 425 | 95.1 | 36.5% | 27.8% | 0.11 |
| gemini-3.5-flash | 512 | 94.5 | 28.5% | 24.6% | 0.11 |
| gemini-3.1-pro | 509 | 93.2 | 26.9% | 23.4% | 0.17 |
| r1-distill-llama-70b | 502 | 91.4 | 34.9% | 17.5% | 0.25 |
Large Language Model-Guided Optimization
Large Language Model-Guided Optimization uses language models to propose, steer, and refine solutions to hard search and design problems.
See all 588 papers