mlsanityData to 14 Oct 2026

LOOPRAG: Enhancing Loop Transformation Optimization with Retrieval-Augmented Large Language Models

arXiv 2512.15766 ↗First posted 12 Dec 2025cs.PL cs.AI cs.DCcited by 1

On the map: Retrieval-augmented generation → RAG for code

Abstract (arXiv)

Loop transformations are semantics-preserving optimization techniques, widely used to maximize objectives such as parallelism. Despite decades of research, applying the optimal composition of loop transformations remains challenging due to inherent complexities, including cost modeling for optimization objectives. Recent studies have explored the potential of Large Language Models (LLMs) for code optimization. However, our key observation is that LLMs often struggle with effective loop transformation optimization, frequently leading to errors or suboptimal optimization, thereby missing opportunities for performance improvements. To bridge this gap, we propose LOOPRAG, a novel retrieval-augmented generation framework designed to guide LLMs in performing effective loop optimization on Static Control Part. We introduce a parameter-driven method to harness loop properties, which trigger various loop transformations, and generate diverse yet legal example codes serving as a demonstration source. To effectively obtain the most informative demonstrations, we propose a loop-aware algorithm based on loop features, which balances similarity and diversity for code retrieval. To enhance correct and efficient code generation, we introduce a feedback-based iterative mechanism that incorporates compilation, testing and performance results as feedback to guide LLMs. Each optimized code undergoes mutation, coverage and differential testing for equivalence checking. We evaluate LOOPRAG on PolyBench, TSVC and LORE benchmark suites, and compare it against compilers (GCC-Graphite, Clang-Polly, Perspective and ICX) and representative LLMs (DeepSeek and GPT-4). The results demonstrate average speedups over base compilers of up to 11.20×, 14.34×, and 9.29× for PolyBench, TSVC, and LORE, respectively, and speedups over base LLMs of up to 11.97×, 5.61×, and 11.59×.

Key facts. Cited by 1 paper in the map (data through 14 Oct 2026). Placed in RAG for code, one of 15 directions in Retrieval-augmented generation. Builds on 17 of its 69 references that are in the map. First posted on arXiv 12 Dec 2025.

Builds on

17 of 69 references.

References · 17

  1. 2020Language Models are Few-Shot Learnerscited by 32,419
  2. 2023Self-Refine: Iterative Refinement with Self-Feedbackcited by 3,442
  3. 2023Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generationcited by 1,391
  4. 2021BEIR: A Heterogenous Benchmark for Zero-shot Evaluation of Information Retrieval Modelscited by 1,252
  5. 2023C-Pack: Packed Resources For General Chinese Embeddingscited by 578
  6. 2019SPoC: Search-based Pseudocode to Codecited by 176
  7. 2023Large Language Models for Compiler Optimizationcited by 52
  8. 2024GISTEmbed: Guided In-sample Selection of Training Negatives for Text Embedding Fine-tuningcited by 40
  9. 2024Meta Large Language Model Compiler: Foundation Models of Compiler Optimizationcited by 39
  10. 2021A Deep Learning Based Cost Model for Automatic Code Optimizationcited by 33
  11. 2024Search-Based LLMs for Code Optimizationcited by 28
  12. 2024LLM-Vectorizer: LLM-based Verified Loop Vectorizercited by 25
5 more
  1. 2023Supersonic: Learning to Generate Source Code Optimizations in C/C++cited by 16
  2. 2025Language Models for Code Optimization: Survey, Challenges and Future Directionscited by 15
  3. 2024Compiler generated feedback for Large Language Modelscited by 9
  4. 2024Structured Code Representations Enable Data-Efficient Adaptation of Code Language Modelscited by 3
  5. 2025Fast, Fine-Grained Equivalence Checking for Neural Decompilerscited by 2

Built on by

Cited by year (2026 to 14 Oct)

Citing papers per year: 2026: 1.

1 paper.

Similar, not cited

Close in wording, no citation either way

  1. 2025Let's Revise Step-by-Step: A Unified Local Search Framework for Code Generation with LLMs
  2. 2025Agentic Auto-Scheduling: An Experimental Study of LLM-Guided Loop Optimization
  3. 2026From Brute Force to Semantic Insight: Performance-Guided Data Transformation Design with LLMs
  4. 2024Should AI Optimize Your Code? A Comparative Study of Classical Optimizing Compilers Versus Current Large Language Models
  5. 2026Are you Synthesizing or Recalling? Evaluating LLMs on Algorithmic Code Retrieval
  6. 2025LLM Program Optimization via Retrieval Augmented Search
  7. 2024CodeRAG-Bench: Can Retrieval Augment Code Generation?
  8. 2024Symbolic Prompt Program Search: A Structure-Aware Approach to Efficient Compile-Time Prompt Optimization