arXiv:2602.03588cs.CLcs.PL2026-02中稿 · SETTA'25

提出高效算法求解程序控制流图上的部分约束满足问题。

Efficient Algorithms for Partial Constraint Satisfaction Problems over Control-flow Graphs

  • 基于系列-并行-循环分解,设计线性时间算法解决控制流图上的部分约束问题。
  • 在固定变量域大小下,算法时间复杂度为线性,实测优化任务提速四倍。
  • 适用于寄存器分配、代码优化等编译器任务,适合编译器研究者与系统开发者。

本文研究程序控制流图上的部分约束满足问题(PCSP),该问题可统一建模多种经典编译优化任务,如寄存器分配、寿命最优推测冗余消除(LOSPRE)和银行选择指令最优放置。控制流图具有稀疏且可分解的特性,本文采用系列-并行-循环(SPL)分解方法,提出一种针对SPL图的通用算法,时间复杂度为 $O(|G| imes |D|^6)$,其中 $|G|$ 为图的大小,$|D|$ 为变量域大小。当 $|D|$ 固定时,算法为线性时间。该算法统一了此前针对寄存器分配与LOSPRE的SPL方法。实验显示,在银行选择优化任务上,运行时间比现有最佳方法快四倍。

原文摘要 · Abstract (English)

In this work, we focus on the Partial Constraint Satisfaction Problem (PCSP) over control-flow graphs (CFGs) of programs. PCSP serves as a generalization of the well-known Constraint Satisfaction Problem (CSP). In the CSP framework, we define a set of variables, a set of constraints, and a finite domain $D$ that encompasses all possible values for each variable. The objective is to assign a value to each variable in such a way that all constraints are satisfied. In the graph variant of CSP, an underlying graph is considered and we have one variable corresponding to each vertex of the graph and one or several constraints corresponding to each edge. In PCSPs, we allow for certain constraints to be violated at a specified cost, aiming to find a solution that minimizes the total cost. Numerous classical compiler optimization tasks can be framed as PCSPs over control-flow graphs. Examples include Register Allocation, Lifetime-optimal Speculative Partial Redundancy Elimination (LOSPRE), and Optimal Placement of Bank Selection Instructions. On the other hand, it is well-known that control-flow graphs of structured programs are sparse and decomposable in a variety of ways. In this work, we rely on the Series-Parallel-Loop (SPL) decompositions as introduced by~\cite{RegisterAllocation}. Our main contribution is a general algorithm for PCSPs over SPL graphs with a time complexity of \(O(|G| \cdot |D|^6)\), where \(|G|\) represents the size of the control-flow graph. Note that for any fixed domain $D,$ this yields a linear-time solution. Our algorithm can be seen as a generalization and unification of previous SPL-based approaches for register allocation and LOSPRE. In addition, we provide experimental results over another classical PCSP task, i.e. Optimal Bank Selection, achieving runtimes four times better than the previous state of the art.

编译优化约束满足控制流图算法设计

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。