Parameterized Algorithms and Complexity for Function Merging with Branch Reordering
Amir Kafshdar Goharshady, Kerim Kochekov, Tian Shu, Ahmed Khaled Zaher
摘要
Binary size reduction is an increasingly important optimization objective for compilers, especially in the context of mobile applications and resource-constrained embedded devices. In such domains, binary size often takes precedence over compilation time. One emerging technique that has been shown effective is function merging, where multiple similar functions are merged into one, thereby eliminating redundancy. The state-of-the-art approach to perform the merging, due to Rocha et al. [CGO 2019, PLDI 2020], 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 𝑖 has size 𝑛 𝑖 , branching factor 𝑏 𝑖 , and nesting depth 𝑑 𝑖 . 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 𝑛 = max(𝑛 1 , 𝑛 2 ), and define 𝑏, 𝑑 similarly. Our results are as follows:
• A simple algorithm running in time 2 O (𝑏𝑑 ) 𝑛 2 , establishing that the problem is fixed-parameter tractable (FPT )
with respect to all four parameters 𝑏 1 , 𝑑 1 , 𝑏 2 , 𝑑 2 .
• An algorithm running in time 2 O (𝑏𝑑 2 ) 𝑛 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 𝑑 1 , 𝑏 2 , 𝑑 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.
问 Lune
几分钟读透这篇 Paper,不用再花一下午。
Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。
脉络
它引用的 Paper1
相关 Paper
- A New Approach to Optimal Function Inlining for Code Size Minimization via E-graphsAmir K. Goharshady, Chun Kit Lam, Andreas Pavlogiannis, Ahmed Khaled ZaherOOPSLA 2026 · 1 次引用
- Equivariant Deep Weight Space AlignmentAviv Navon, Aviv Shamsian, Ethan Fetaya, Gal Chechik 等ICML 2024 · 31 次引用
- Symbolic Functional Decomposition: A Reconfiguration ApproachMateus de Oliveira Oliveira, Wim Van den BroeckAAAI 2025
- Fast FPT-approximation of branchwidthFedor V. Fomin, Tuukka KorhonenSTOC 2022 · 12 次引用
- Efficient Latency-Aware CNN Depth Compression via Two-Stage Dynamic ProgrammingJinuk Kim, Yeonwoo Jeong, Deokjae Lee, Hyun Oh SongICML 2023 · 1 次引用
