Parameterized Algorithms and Complexity for Function Merging with Branch Reordering

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 F1, F2, where each Fi has size ni, branching factor bi, and nesting depth di. Our task is to reorder the branches of F1 and F2 in a way that yields linearizations achieving the maximum sequence alignment. Let n=(n1, n2), and define b, d similarly. Our results are as follows: - A simple algorithm running in time 2O(bd) n2, establishing that the problem is fixed-parameter tractable (FPT) with respect to all four parameters b1,d1, b2, d2. - An algorithm running in time 2O(bd2) n7, 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 d1, b2, d2. 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.

0

Turn this paper into a lesson

ArcXiv compiles a structured reading guide from this paper's metadata: plain-English importance, contributions, prerequisite concepts, which sections to read first, flashcards, and a quiz. Grounded in the abstract, never invented.

Discussion (0)

Sign in to join the discussion.

Loading comments…