VecTrans: Enhancing Compiler Auto-Vectorization through LLM-Assisted Code Transformations

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Zheng, Zhongchun, Wu, Kan, Cheng, Long, Li, Lu, Rocha, Rodrigo C. O., Liu, Tianyi, Wei, Wei, Zeng, Jianjiang, Zhang, Xianwei, Gao, Yaoqing
Format: Preprint
Published: 2025
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866913874039537664
author Zheng, Zhongchun
Wu, Kan
Cheng, Long
Li, Lu
Rocha, Rodrigo C. O.
Liu, Tianyi
Wei, Wei
Zeng, Jianjiang
Zhang, Xianwei
Gao, Yaoqing
author_facet Zheng, Zhongchun
Wu, Kan
Cheng, Long
Li, Lu
Rocha, Rodrigo C. O.
Liu, Tianyi
Wei, Wei
Zeng, Jianjiang
Zhang, Xianwei
Gao, Yaoqing
contents Auto-vectorization is a fundamental optimization for modern compilers to exploit SIMD parallelism. However, state-of-the-art approaches still struggle to handle intricate code patterns, often requiring manual hints or domain-specific expertise. Large language models (LLMs), with their ability to capture intricate patterns, provide a promising solution, yet their effective application in compiler optimizations remains an open challenge due to issues such as hallucinations and a lack of domain-specific reasoning. In this paper, we present VecTrans, a novel framework that leverages LLMs to enhance compiler-based code vectorization. VecTrans first employs compiler analysis to identify potentially vectorizable code regions. It then utilizes an LLM to refactor these regions into patterns that are more amenable to the compilers auto-vectorization. To ensure semantic correctness, VecTrans further integrates a hybrid validation mechanism at the intermediate representation (IR) level. With the above efforts, VecTrans combines the adaptability of LLMs with the precision of compiler vectorization, thereby effectively opening up the vectorization opportunities. experimental results show that among all TSVC functions unvectorizable by GCC, ICC, Clang, and BiSheng Compiler, VecTrans achieves an geomean speedup of 1.77x and successfully vectorizes 24 of 51 test cases. This marks a significant advancement over state-of-the-art approaches while maintaining a cost efficiency of $0.012 per function optimization for LLM API usage.
format Preprint
id arxiv_https___arxiv_org_abs_2503_19449
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle VecTrans: Enhancing Compiler Auto-Vectorization through LLM-Assisted Code Transformations
Zheng, Zhongchun
Wu, Kan
Cheng, Long
Li, Lu
Rocha, Rodrigo C. O.
Liu, Tianyi
Wei, Wei
Zeng, Jianjiang
Zhang, Xianwei
Gao, Yaoqing
Software Engineering
Artificial Intelligence
Machine Learning
Performance
Auto-vectorization is a fundamental optimization for modern compilers to exploit SIMD parallelism. However, state-of-the-art approaches still struggle to handle intricate code patterns, often requiring manual hints or domain-specific expertise. Large language models (LLMs), with their ability to capture intricate patterns, provide a promising solution, yet their effective application in compiler optimizations remains an open challenge due to issues such as hallucinations and a lack of domain-specific reasoning. In this paper, we present VecTrans, a novel framework that leverages LLMs to enhance compiler-based code vectorization. VecTrans first employs compiler analysis to identify potentially vectorizable code regions. It then utilizes an LLM to refactor these regions into patterns that are more amenable to the compilers auto-vectorization. To ensure semantic correctness, VecTrans further integrates a hybrid validation mechanism at the intermediate representation (IR) level. With the above efforts, VecTrans combines the adaptability of LLMs with the precision of compiler vectorization, thereby effectively opening up the vectorization opportunities. experimental results show that among all TSVC functions unvectorizable by GCC, ICC, Clang, and BiSheng Compiler, VecTrans achieves an geomean speedup of 1.77x and successfully vectorizes 24 of 51 test cases. This marks a significant advancement over state-of-the-art approaches while maintaining a cost efficiency of $0.012 per function optimization for LLM API usage.
title VecTrans: Enhancing Compiler Auto-Vectorization through LLM-Assisted Code Transformations
topic Software Engineering
Artificial Intelligence
Machine Learning
Performance
url https://arxiv.org/abs/2503.19449