LOOPRAG: Enhancing Loop Transformation Optimization with Retrieval-Augmented Large Language Models
Yijie Zhi, Yayu Cao, Jianhua Dai, Xiaoyang Han, Jingwen Pu, Qinran Wu, Sheng Cheng, Ming Cai
摘要
Loop transformations are semantics-preserving optimization techniques applied at the source level, widely used in compilers to maximize objectives such as vectorization and parallelism. Despite decades of research, applying the optimal composition of loop transformations remains challenging due to inherent complexities, including dependency analysis and 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 significant 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 (SCoP). 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 generated by LOOPRAG undergoes mutation, coverage and differential testing to perform 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 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×.
问问这篇 Paper
智能体会读完全文。
Lune 把这篇 Paper 索引到了最后一个公式,引用它的顶会 Paper 也一样。你提问,回答直接引用原文。
它引用的顶会 Paper10
- Language Models are Few-Shot LearnersTom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah 等NeurIPS 2020 · 被引用 64,255 次
- Self-Refine: Iterative Refinement with Self-FeedbackAman Madaan, Niket Tandon, Prakhar Gupta, Skyler Hallinan 等NeurIPS 2023 · 被引用 4,972 次
- Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code GenerationJiawei Liu, Chunqiu Steven Xia, Yuyao Wang, Lingming ZhangNeurIPS 2023 · 被引用 2,317 次
- Self-Consistency Improves Chain of Thought Reasoning in Language ModelsXuezhi Wang, Jason Wei, Dale Schuurmans, Quoc V. Le 等ICLR 2023 · 被引用 681 次
- Automatic Chain of Thought Prompting in Large Language ModelsZhuosheng Zhang, Aston Zhang, Mu Li, Alex SmolaICLR 2023 · 被引用 234 次
相关 Paper
- SRACG: A Code Generation Framework with Selective Retrieval AugmentationMengzhen Wang, Shukai Ma, Songwen Gong, Jiexin Wang 等AAAI 2026
- RTLFixer: Automatically Fixing RTL Syntax Errors with Large Language ModelYunda Tsai, Mingjie Liu, Haoxing RenDAC 2024 · 被引用 95 次
- Example Quality Matters: Multi-Aspects Example Augmentation for Private Library ProgrammingYuhao Li, Haifeng Sun, Xuesong Zhang, Shu Yao 等ACL 2026
- CIRBench: Evaluating Large Language Models as LLVM IR OptimizersZi Yang, Haifeng Ding, Fei Liu, Yingying Cheng 等ICML 2026
- Weak-to-Strong Prompts with Lightweight-to-Powerful LLMs for High-Accuracy, Low-Cost, and Explainable Data TransformationChanglun Li, Chenyu Yang, Yuyu Luo, Ju Fan 等VLDB 2025 · 被引用 6 次
