Parameterized Algorithms and Complexity for Function Merging with Branch Reordering

πŸ“… 2026-04-13
πŸ“ˆ Citations: 0
✨ Influential: 0
πŸ“„ PDF
πŸ€– AI Summary
This work addresses the limitations of fixed branch ordering in function merging, which constrains optimization potential, and investigates the computational complexity when branch reordering is permittedβ€”a setting that renders the problem NP-hard. For the first time, the problem is systematically studied through the lens of parameterized complexity, formulated as a parameterized sequence alignment task. The analysis reveals that the branching factor $b$ and nesting depth $d$ (or an alternative depth measure $d_2$) critically govern tractability. Leveraging this insight, we design fixed-parameter tractable (FPT) algorithms with running times $2^{O(bd)} n^2$ and $2^{O(bd_2)} n^7$, respectively. Moreover, we establish that the problem remains NP-hard even when certain parameters are fixed, thereby delineating a fine-grained boundary of its computational complexity.

Technology Category

Search and Optimization: Combinatorial OptimizationConstraint Satisfaction and Optimization: SearchKnowledge Representation and Reasoning: Computational Complexity of Reasoning

Application Category

Graph Algorithms and Modeling for the Web: Efficient manipulation of static and dynamic Web-related graphsSearch and Retrieval-Augmented AI: Web learning to rank, online learning, and counterfactual learning for rankingWeb Mining and Content Analysis: Bridging structured and unstructured data
πŸ“ Abstract
Binary size reduction is an increasingly important optimization objective for compilers. One emerging technique is function merging, where multiple similar functions are merged into one, thereby eliminating redundancy. The SOTA approach to perform the merging is based on sequence alignment, where functions are viewed as linear sequences of instructions that are then matched in a way maximizing their alignment. In this paper, we consider a significantly generalized formulation of the problem by allowing reordering of branches within each function, subsequently allowing for more flexible matching and better merging. We show that this makes the problem NP-hard, and thus we study it through the lens of parameterized algorithms and complexity, where we identify certain parameters of the input that govern its complexity. We look at two natural parameters: the branching factor and nesting depth of input functions. Concretely, our input consists of two functions $F_1, F_2,$ where each $F_i$ has size $n_i,$ branching factor $b_i,$ and nesting depth $d_i.$ Our task is to reorder the branches of $F_1$ and $F_2$ in a way that yields linearizations achieving the maximum sequence alignment. Let $n=\max(n_1, n_2),$ and define $b, d$ similarly. Our results are as follows: - A simple algorithm running in time $2^{O(bd)} n^2,$ establishing that the problem is fixed-parameter tractable (FPT) with respect to all four parameters $b_1,d_1, b_2, d_2.$ - An algorithm running in time $2^{O(bd_2)} n^7,$ showing that even when one of the functions has an unbounded nesting depth, the problem remains in FPT. - A hardness result showing that the problem is NP-hard even when constrained to constant $d_1, b_2, d_2.$ To the best of our knowledge, this is the first systematic study of function merging with branch reordering from an algorithmic or complexity-theoretic perspective.
Problem

Research questions and friction points this paper is trying to address.

function merging
branch reordering
sequence alignment
parameterized complexity
NP-hard
Innovation

Methods, ideas, or system contributions that make the work stand out.

function merging
branch reordering
parameterized algorithms
fixed-parameter tractability
sequence alignment
A
Amir K. Goharshady
University of Oxford, United Kingdom
K
Kerim Kochekov
Hong Kong University of Science and Technology, Hong Kong
T
Tian Shu
Hong Kong University of Science and Technology, Hong Kong
A
Ahmed Khaled Zaher
Hong Kong University of Science and Technology, Hong Kong