arXiv:2610.24835cs.AIOct 2026

Manuscript Offprint

arXiv:2610.24835

Pattern-Driven Evaluation of LLM Code Optimization: Isolating Compiler-Transcendent Semantic Reasoning

Wesley Lu, Runzhou Liu, Hongru Du, Xinyao Yi

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.

1 Introduction

Large language models (LLMs) are increasingly capable of improving program performance, with recent work demonstrating measurable runtime improvements across a variety of code optimization benchmarks [8; 10; 17; 22; 9; 27]. These results suggest that LLMs may become useful assistants for performance engineering and compiler-assisted software development.

Evaluating optimization capability, however, remains challenging. Unlike functional code generation, optimization success cannot be fully characterized by correctness alone. Modern compilers already perform a wide range of sophisticated optimizations, including inlining, vectorization, loop transformations, and interprocedural analysis [1]. Consequently, performance gains reported by existing benchmarks often conflate optimizations generated by the model with transformations that are already within the capabilities of modern compiler technology. This ambiguity raises two important questions. First, can LLMs identify optimization opportunities that remain beyond aggressive compiler optimization? Second, when a model proposes an optimization strategy, does it actually realize that transformation in the generated code? Existing optimization benchmarks primarily evaluate end-to-end speedup and provide limited insight into either question.

To address these limitations, we introduce PatternBench, a benchmark designed around compiler-transcendent optimization opportunities—optimization patterns that survive aggressive compiler optimization and therefore require reasoning beyond standard compiler analyses. In addition to measuring performance improvement, PatternBench incorporates an AST-based optimization faithfulness analysis that verifies whether the intended optimization transformation is actually realized in the generated program.

Using a collection of frontier, open-weight, and fine-tuned language models, we study both optimization effectiveness and optimization faithfulness. Our results reveal substantial variation in compiler-transcendent optimization capability across models and show that optimization faithfulness is strongly associated with realized performance gains. Models that consistently implement intended transformations achieve significantly larger speedups, while models with lower faithfulness frequently fail to translate optimization plans into effective code modifications. The contributions of this work are as follows:

• A benchmark of compiler-transcendent optimization tasks designed to isolate optimization opportunities that survive aggressive compiler optimization.

• An AST-level verification methodology that enables process-aware evaluation of optimization behavior through optimization faithfulness.

• A comparative study of frontier, open-weight, and fine-tuned language models on compiler-transcendent optimization.

• Empirical evidence that optimization faithfulness predicts realized performance gains and exposes optimization failures missed by speedup-only evaluation.

References (31)