PLDI 2025
Mon 16 - Fri 20 June 2025 Seoul, South Korea

Realizing quantum computing algorithms often requires instantiating and using ancilla qubits. These spare qubits are used only temporarily in the quantum circuit and thus are often utilized with encode-compute-decode operations. In particular, many recently developed high-level quantum programming languages heavily utilize ancilla qubits to maintain internal states with similar gate sequences to implement various programming constructs. We present SPARE a quantum circuit optimizer that breaks down and restructures these encode-compute-decode patterns and uses ancilla qubit state information for circuit optimization. SPARE achieves up to 2.2× improvement in circuit depth gates against the Spire and up to 10.6× improvement in circuit depth against the Unqomp compilers for Tower and Silq high-level languages, respectively. SPARE also achieves up to 1.68× lower circuit depth compared to gate-level rewriting tools like Quartz with an exponentially faster runtime, bridging the gap between gate-level optimizers and quantum-language compilers.