Dataflow-Based Optimization for Quantum Intermediate Representation Programs
Junjie Luo, Haoyu Zhang, Jianjun Zhao
TL;DR
This work targets optimization of quantum intermediate representation programs by introducing QDFO, a dataflow-based technique built on the LLVM toolchain. The approach combines a preprocessing stage (QIR-Inline and QIR-Loop-Unroll) that rewrites QIR into forms amenable to LLVM optimizations with a runtime-oriented execution stage (QDFO-Load, QDFO-Create, QIR-DCE) that eliminates redundant loads and creations and cleans QIR-specific dead code. Evaluations on the IBM Quantum Challenge Dataset show substantial instruction reductions, especially for larger circuits, and case studies on Toffoli decomposition and Grover’s algorithm demonstrate practical readability gains and concrete reductions in load/create operations. Overall, QDFO enables leveraging the mature LLVM optimization ecosystem for quantum programs, offering a first step toward more scalable, hardware-agnostic quantum program optimization and highlighting directions for future verification and classical-quantum integration enhancements.
Abstract
This paper proposes QDFO, a dataflow-based optimization approach to Microsoft QIR. QDFO consists of two main functions: one is to preprocess the QIR code so that the LLVM optimizer can capture more optimization opportunities, and the other is to optimize the QIR code so that duplicate loading and constructing of qubits and qubit arrays can be avoided. We evaluated our work on the IBM Challenge Dataset, the results show that our method effectively reduces redundant operations in the QIR code. We also completed a preliminary implementation of QDFO and conducted a case study on the real-world code. Our observational study indicates that the LLVM optimizer can further optimize the QIR code preprocessed by our algorithm. Both the experiments and the case study demonstrate the effectiveness of our approach.
